Walked through the install steps over at http://www.php-maven.org/tags/2.0.0/php-lib-5min.html ...
Using: Maven 3.0.3,
PHP 5.3.13,
maven-php-plugin 2.0.0,
phpunit 3.6.10.
The project has only the stub LibraryClass.php and LibraryClassTest.php dropped in by the project builder call.
When i run 'mvn package' in the last step of their guide i'm getting:
Caused by: org.apache.xbean.recipe.MissingAccessorException: Unable to find a valid setter method: public void org.phpmaven.phpunit.impl.PhpunitSupport360.setSingleInvocation(...)
Looking at the javadoc for PhpunitSupport360, that method doesn't exist. As everything was installed by maven (and pear) i'm not sure what's going on. The guide says to user Maven v3.
Seems that it loads a wrong plugin. For me it works.
You shoud ensure that it really loads the correct plugin versions. If you try to change the php-maven plugin version (f.e. to 2.0-SNAPSHOT) you should use the corresponding php-parent-pom and use the property ${phpmaven.plugin.version} as version. or simply remove any version number from the php-maven plugins because the version numbers are managed by the php-parent-pom.
You may look at the output of mvn help:effective-pom to see what is going on and what versions for the plugins are used.
Related
I have setup my environment as follows: Wamp 3 with PHP7.1.33 version, composer 2 and the Symfony binary.
But when I try to run symfony new my_project_name --version=4.4 --full I get this error:
Creating a "symfony/website-skeleton" project at "./my_project_name"
Your version of PHP, 5.4.12, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.
[InvalidArgumentException]
Could not find package symfony/website-skeleton with version 4.4.* in a version installable using your PHP version,
PHP extensions and Composer version.
As mentionned in the error, PHP 5.4.12 is used, but when I run php --version I get 7.1.33 version.
I haven't used either WAMP or the Symfony binary, but on the documentation it says:
If you have multiple PHP versions installed on your computer, you can tell Symfony which one to use creating a file called .php-version at the project root directory
If you have multiple PHP versions installed, apparently the tool attempts to find them and list them if you use the symfony local:php:list command. No idea how it works or how reliable it is, but should tell you if it's able to detect your PHP 7 runtime.
More importantly, despite the poor advice on Symfony part, you do not really need to use the symfony binary to create a project. The binary simply calls composer, so why not call composer directly? That way you can be sure you are using the PHP and Composer's versions you want and expect, instead of relying on an intermediary.
Just do:
composer create-project symfony/website-skeleton your-project-name ^4.4
(this is what you get by using the --full flag, if you do not use it you simply install symfony/skeleton, which includes less components out of the box).
As an aside, naming the binary symfony was a really poor choice on Symfony's part, as it makes it almost impossible to search for issues related to the tool and not the framework. Or to suggest to use the binary instead of using composer directly, adding a layer of opacity for many users.
My problem is, I don't know how to install properly scotch-panels in Laravel project. I installed scotch-panels by:
npm install scotch-panels
and compile it by:
npm run dev
but I have error in console, when I used function from scotch-panels library:
Uncaught TypeError: $(...).scotchPanel is not a function
I tried extract module to vendor.js (like documentation said), but node states:
Module not found: Error: Can't resolve 'scotch-panels' in [...]
Unfortunately, link manually library it's not a option. I add that jQuery of course works properly.
I tried with other modules but once it's working, once not. I really don't know, what happened here.
Any help is highly appreciated with this, because I'm confused now.
After many comes and goes I managed to install the MongoDB Driver for PHP 5.6 and made it work on OSX El Capitan. (The way it worked was using Homebrew)
To start working on a project I created the folder for the project and using Composer installed the required packages I needed. Between theese packages I required mongodb/mongodb which is the recomended mongo php library to use by the php Manual on line and in the driver github page.
The problem I found is that Eclipse is resolving the classes in the \MongoDB\ namespace but not in the \MongoDB\BSON\ namespace. If I check what Composer installed in the vendor folder I am able to see that the \MongoDB\BSON\ classes in fact are missing. On the other hand if I run the program in the PHP included webserver, it executes as expected.
So my question is how can do or what am I missing for Eclipse to find the missing classes. Are they defined somewhere else?
If this is not possible because they are compiled into a binary library and I have no way to resolve them, Is there any way to have Eclipse not showing these particular classes as mistakes?
Example of class that runs ok in the webserver, but is highlighted as an error in Eclipse:
$fecha_creacion = new MongoDB\BSON\UTCDateTime();
Reading this post and not finding anything newer on the subject I arrived to the conclusion that developers of the driver don't provide the php sources and leave it to the IDE developers to provide STUBs for the different fuctions of the driver in a way the IDE can recognize the functions and provide syntax checking and documentations popups.
Following this question, I finally ended up finding a JetBrains GitHub where there are many different stubs for PHPStrom, this one among them.
So I copied the file and added it to my project as part of the sources. And that solved my problem.
I wonder if someone can help me. I've been handed in a Cake PHP app that I need to 1) add minor changes 2) deploy. I've never really worked with Cake before and was wondering whether do I need to anything in order for it to work?
For instance, With a Node app, you need to install modules npm install. With a Rails app you'll likely need to install the gems bundle install.
Is there something similar with Cake? I've set the localhost server, but when I try to access the url I get all sort of errors. Some I've fixed (missing environment settings which I just override the Redis host and port). The latest one is:
{
"exception":{
"class":"MissingControllerException",
"code":404,
"message":"Controller class Controller could not be found.",
"file":"\/Library\/WebServer\/Documents\/php\/oompbe\/vendors\/cakephp\/lib\/Cake\/Routing\/Dispatcher.php",
"line":154,
"trace":[
"#0 \.../app\/webroot\/index.php(109): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))",
"#1 {main}"
]
}
}
PS: What's up with all the crazy \/\/?
PPS: Can I find out the version Cake I'm running?
CakePHP is just php. As most properly done php apps these days it comes with composer. I recommend you to read at least the basics of it's manual. Composer is an awesome tool.
git clone <repo>
cd <reponame>
composer install
If you start a new Cake application the official documentation tells you how to this as well:
composer create-project --prefer-dist cakephp/app [app_name]
If you want to automate things further composer provides you callback scripts. They'll allow you to automate tasks, basically trigger commands, after different actions. This is pretty useful to build assets after a composer update for example. I recommend you to not put lots of commands into that section but instead have dedicated script files you trigger by the callbacks.
Can I find out the version Cake I'm running?
If installed via composer it is usually in vendor/cakephp/cakephp/version.txt. Check the content of that file.
Let me just start by saying that I've posted this to multiple forums and even tried to get help on the ZF IRC channel. I've been Googling for a straight week and still no results. I've read a lot of Q's and A's on this site in the past, so I figured I'd make an account and try asking you.
(Yes, I've searched previously asked questions, but none of the answers helped me.)
I'm trying to learn how to use Zend Framework for a new project that I've joined. For compatibility reasons they are using Zend 1 (and not the newer Zend 2). I have found and followed a number of online and physical book tutorials but I've the same results over and over again.
So here goes (this are the instructions that all the tutorials give). I went to framework.zend.com and downloaded the full version of ZF 1.12.
I unzipped the contents
I moved the library folder to a safe directory where it won't be modified
I moved the contents of the bin folder to same directory as my PHP executable
I changed the include_path in my php.ini file to include the library directory
I updated my Windows PATH variable to make sure it included the path to the PHP executable
I ran
zf --help
This command worked as intended. I also successfully ran zf show version (Zend Framework Version 1.12.7).
I ran the command
zf create project myproject
Upon doing this, I receiving the following error message:
Fatal error: Class 'PHPUnit_Framework_TestCase' not found in D:\Zend\library\Zend\Test\PHPUnit\ControllerTestCase.php on line 48
That particular line in question is a class declaration that extends PHPUnit_Framework_TestCase. I don't know where PHPUnit_Framework_TestCase is defined. It is not in any of the files or directories that came in the single ZIP file that I downloaded from Zend. I even ran grep on all files and folders searching for the string "class PHPUnit_Framework_TestCase" but it printed no results.
Some have suggested that I don't have PHPUnit installed (which is obvious to me now). The part that bugs me is that absolutely none of the tutorials that I read mention anything about installing PHPUnit before hand or how to install it or what dependencies Zend has on it. Many of these were beginner tutorials that assumed you only had a basic knowledge of PHP, and it's pretty shocking to me that none even mentioned PHPUnit. If PHPUnit was that important I would think that the file I downloaded from Zend would have included it. I guess not.
So I went online again and got the PHAR file for PHPUnit, but now what? I tried putting it in multiple different directories but I still get the same error. Am I not supposed to use a PHAR file? Should I be using the actual files instead?
What do I have to do to get ZF to recognize PHPUnit, resolve this error and create my first ZF project?
Additional Info:
Windows 7, XAMPP Server (running on localhost), PHP 5.5.6
Assuming you have PHPUnit installed and it is on your include path (Bearing in mind that ZF1 only officially supports PHPUnit 3.4.x and definitely doesn't support anything above PHPUnit 3.5.x, so if you're using XAMPP you may have to downgrade PHPUnit as described here). The problem is most probably due to this commit, where the require calls for PHPUnit were stripped out in favour of using an autoloader. The ZF tool over CLI doesn't set up an autoloader though, so PHPUnit is not found because it is simply not required! To fix you can return these lines to the start of Zend/Test/PHPUnit/ControllerTestCase.php
/** #see PHPUnit_Runner_Version */
require_once 'PHPUnit/Runner/Version.php';
/**
* Depending on version, include the proper PHPUnit support
* #see PHPUnit_Autoload
*/
require_once (version_compare(PHPUnit_Runner_Version::id(), '3.5.0', '>=')) ? 'PHPUnit/Autoload.php' : 'PHPUnit/Framework.php';
It's worth noting that even with the error you mention, ZF tool should still work correctly when setting up a project, it just won't produce unit test actions (you'll have to make them yourself). If you don't want to downgrade your XAMPP PHPUnit version you should be able to add the correct version locally to your project using composer as described here.
Update Jan 2015:
Downgrading PHPUnit for XAMPP is no longer necessary as ZF1 has supported at least version 4.1 of PHPUnit since 1.12.7 (I've not tested above 4.1). This is helpful as PHPUnit has completely removed their deprecated Pear repository as of December 2014, which means you can't download versions older than 3.7 anymore anyway! (Currently XAMPP ships with PHPUnit 3.6). These days though it's probably worth chucking XAMPP for Vagrant and globally installing PHPUnit 4.1 via Composer during Vagrant provisioning.
I recommend using Composer to load both ZF and PHPUnit. Then make sure to include the Composer autoload.php file as your/in your phpunit boostrap file.
I had the same problem when I set up my laptop as a second development machine and downloaded the newest version of Zend Framework 1 (1.12.9). Whenever I tried to create a new action in a controller, I got the same error. Yet on my main computer, it worked fine.
I realized it was because the version of ZF1 I had in my php includes path was actually 1.11.11. So I went and got 1.11.14 from the ZF archives page, put it in the includes directory, and it worked fine.
Not entirely sure if this is the best way to make it work, since it is an older version, but at least it does work. And until someone actually comes on here and offers a better solution, that's what I intend to stick with.
You can create or edit a .zf.ini file in your home directory (~/.zf.ini or C:\Users\YOUR_ACCOUNT\.zf.ini on Windows)
php.include_path = "PATH_TO_THE_LIBRARY_FOLDERS_CONTAINING_ZEND_AND_PHPUnit"
basicloader.classes.0 = "PHPUnit_Framework_SelfDescribing"
basicloader.classes.1 = "PHPUnit_Framework_Test"
basicloader.classes.2 = "PHPUnit_Framework_Assert"
basicloader.classes.3 = "PHPUnit_Framework_TestCase"
If you are using Netbeans on Windows it could looks like this (you can put several library folder, just separate them with a semicolon ;) :
php.include_path = "C:\Users\romain\dev\ZendFramework-1.12.17\library;C:\Program Files\NetBeans 8.1\php\zend;C:\xampp\php\pear"
basicloader.classes.0 = "NetBeansCommandsProvider"
basicloader.classes.1 = "PHPUnit_Framework_SelfDescribing"
basicloader.classes.2 = "PHPUnit_Framework_Test"
basicloader.classes.3 = "PHPUnit_Framework_Assert"
basicloader.classes.4 = "PHPUnit_Framework_TestCase"