I'v been trying to get phpunit up and running but for some reason i'm stuck with the following error:
Warning: require(PHPUnit/Autoload.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 44
Fatal error: require(): Failed opening required 'PHPUnit/Autoload.php' (include_path='.:') in /usr/bin/phpunit on line 44
Does anybody have a clue how to solve this?
Thanks in advance!
Peter
Your include path is not setup. Follow the instructions at http://pear.php.net/manual/en/installation.checking.php
Also check if you installed phpunit in the correct directory:
$ pear list-files phpunit/phpunit
PHPUnit/Autoload.php should be listed there, in the patch you added to the include path.
Update: the problem was that #Peter had 2 php.ini files, and he edited the wrong one.
Find the correct one with
$ php --ini
Irakli's post was the most helpful.
I'm on Mac OS X 10.7.2 and I use Homebrew to install packages. Homebrew put php in /usr/local/bin/php.
Following Irakli's hint that phpunit is using a different version on of PHP (even though it was using the same php.ini file), I edited /usr/bin/phpunit, replacing this:
#!/usr/bin/php
with this:
#!/usr/local/bin/php
(Irakli's suggestion of "#!/usr/bin/env php" didn't work for me)
Now phpunit can find "File/Iterator/Autoload.php" which is was having trouble with before, so I guess it's in the path now.
On Mac Lion I added the include path:
/usr/lib/php/pear/
to /private/etc/php.ini which solved the error.
In some cases (e.g. when using brew-installed PHP on OS-X Leopard/Snow Leopard/Lion) the problem can be that there're multiple php versions installed and phpunit is picking wrong one.
There's an easy solution, sudo-edit /usr/bin/phpunit and replace #!/usr/bin/php with #!/usr/bin/env php
Somebody should probably submit a bug to phpunit, referring to PHP executable directly is really careless.
Related
I'm trying to make some PhpUnit test on Magento with using ecomdev (https://github.com/EcomDev/EcomDev_PHPUnit).
I've correctly installed modman, PEAR and related packages dependencies (I'm on Ubuntu server 12.04 through a Virtualbox).
What is really strange is, after the step 2, from ecomdev procedure, when I'm trying to start a first "$ phpunit" command, it shows the screen as if I typed "$ phpunit --help".
When I type "$ phpunit --version" it correctly displaying the current version (mean it seems correctly installed).
All advices are welcome.
I have been similar problem on WAMP, WinXP SP3, Apache 2.4, PHP5.4.44, Xdebug v2.3.3, vc10+vc14
I downloaded phpunit.phar from phpunit.de
My error was wrong phpunit.cmd file.
I wrote
#php "%~dp0phpunit.phar"
Correct cmd is
#php "%~dp0phpunit.phar" %*
phpunit needs to know what to run. EcomDev_phpUnit includes a phpunit.xml.dist file that phpunit can use. Neither modman nor modgit installs it in Magento's root by default. You can copy the default version into Magento's webroot from the module's source folder or by installing the module manually.
I used modgit to install EcomDev_phpUnit. Here is the copy command I used to copy the file:
cp .modgit/ecomdev_phpunit/source/phpunit.xml.dist .
Once in place, phpunit should give you something like this:
$ phpunit
PHPUnit 3.7.28 by Sebastian Bergmann.
Configuration read from /path/to/your/magento/phpunit.xml.dist
There is likely a more correct way to use the included ecomdev-phpunit.php script to copy the phpunit.dist.xml file into place.
I am just getting start with Zend Framework and seem to run into this problem
Testing Note: PHPUnit was not found in your include_path, therefore no
testing actions will be created.
I am on mac 10.8.5, Using Zend Server 6 (free), and Zend Framework 1.12.3
Have pear and phpunit installed
which pear
/usr/local/zend/bin/pear
which phpunit
/usr/local/zend/bin/phpunit
from php info and include_path
Loaded Configuration File /usr/local/zend/etc/php.ini
include_path=".:/usr/local/zend/share/ZendFramework/library:/usr/local/zend/bin/pear:/usr/local/zend/bin/phpunit:/usr/local/zend/share/pear:/usr/local/zend/share/pear/phpunit"
No matter what i put in the include_path, i always get the above notice, PHPUnit was not found in your include path.
I been searching and someone said zf.ini can cause this, and that file should be editted, however i can't seem to find such a file anywhere on my Mac. I do have previous Mamp and Xampp installations, but phpinfo() states the correct php.ini file loaded so i doubt that is the problem
Edit:
Okay so i finally managed to fix it. Using "zf.sh --setup" i found the paths to all the config files, including .zf.ini and how to edit it. The file did not exist, so i had to create it, and adding "include_path" to .zf.ini fixed the issue. However in the end i am overriding the php.ini which was probably being over ridden. I still like to know why adding pear path to php.ini didn't work, hopefully someone can explain that
I am working on Debian Linux / Apache (a VPS at Dreamhost). I have tried to install ZeroMQ (version 3.2.3) as per these instructions. At the first glance, it looks like everything went well.
The sudo make install command proudly reports back that (among others)
Libraries have been installed in: /usr/local/lib
Indeed, here is the ls of /usr/local/lib:
libzmq.a libzmq.so libzmq.so.3.0.0 php python2.5 site_ruby
libzmq.la libzmq.so.3 ocaml pkgconfig python2.6
In order to use ZeroMQ I have added to my php.ini:
extension = /usr/local/lib/libzmq.so
But when I run PHP, I get:
PHP Startup: Invalid library (maybe not a PHP library) '/usr/local/lib/libzmq.so
What am I doing wrong?
update
As per djf's answer, I worked my way through the instructions for PHP bindings (building from Github). Those seem to work. But then, when I run PHP I get:
PHP Warning: PHP Startup:
zmq: Unable to initialize module Module compiled with module API=20060613
PHP compiled with module API=20100525
These options need to match in Unknown on line 0`
Now what?
update 2
Oh, wait a minute. I may know what that is. Dreamhost has PHP 5.2 on the command line. I need PHP 5.4, so I have been calling PHP like so /usr/local/php54/bin/php (this is apparently where the PHP 5.4 executable resides).
However, commands like configure and make use the ordinary, standard PHP. So I needed to upgrade CLI PHP to 5.4.
After that, everything worked. Thanks for the help, everyone!
Seems like you've only installed the C library, hence the error:
PHP Startup: Invalid library (maybe not a PHP library) '/usr/local/lib/libzmq.so
You also have to build the PHP bindings. Check these instructions on howto build them.
I do this for windows but i thinks linux is same.
Just go to http://pecl.php.net/package/zmq/1.1.2/windows and download package that fit with your php version.
Then extract it and coppy 'libzmq.dll' to 'xampp/php' folder, 'php_zmq.dll' to 'xampp/php/etc'.
At the end of 'php.ini' add following line:extension=php_zmq.dll
Don't forget restart your xampp!Good luck
I'm running into an issue trying to get codesniffer working with Xampp (1.7.1). I've got pear running by editing the include_path in php.ini.
When I try to run phpcs I get the following errors:
Warning: include_once(PHP/CodeSniffer/CLI.php): failed to open stream: No such file or directory in C:\xampp\php\phpcs on Line 31
Warning: include_once(): Failed opening 'PHP/Codesniffer/CLI.php' for inclusion (include_path="\xampp\php\pear") in C:\xampp\php\phpcs on line 31
Fatal error: Class 'PHP_CodeSniffer_CLI' not found in C:\xampp\php\phpcs on line 34
Anyone have any idea what's going on here?
It definitely sounds like the PHP include path is wrong, even though PEAR itself is working. It is a bit strange though.
Do you have a \xampp\php\pear\PHP\CodeSniffer\CLI.php file? If not, can you find where it is under the \xampp\php\pear directory?
If it is, for example, actually at \xampp\php\pear\source\pear\PHP\CodeSniffer\CLI.php then you'll need to change your include_path to be \xampp\php\pear\source\pear. But this could then break your PEAR install, which probably means PEAR is not configured correctly.
If this is the case, it's worth uninstalling PHP_CodeSniffer, changing the location of PEAR's php_dir configuration variable, and then reinstalling PHP_CodeSniffer.
For example:
pear uninstall php_codesniffer
pear config-set php_dir \xampp\php\pear
pear install php_codesniffer
(sorry, I'm not sure if pear on windows requires the drive letter in the path, so just check the current value using pear config-get php_dir and adjust the path based on that format.)
I hope that info helps you move forward a bit.
PEAR might have also setup an include path in the phpcs executable (-d include_path="''") which is overriding the default. This is particularly annoying if you forget to create a default php.ini file until after phpcs is installed.
My NetBeans have an option to add a path to a script that runs PHPUnit, however when I try to add this script to my NetBeans I get the error that it doesn't recognize the version. Says that version is ?.?.? and that is not supported. However my PHPUnit version is supported by NetBeans and work perfectly when I run it from the pear installer folder (PHP).
"Selected PHPUnit (version ?.?.?) is too old, upgrade it if possible (the minimum version is 3.3.0)" - I got 3.6.4.
My script looks like this
#!/bin/sh
phpunit --bootstrap MyBootstrap.php --stderr $*
And it works great on linux NetBeans. Just not on my Mac.
And yes it works perfect when I run it in the console.
Thanks a milion
/Marcus
I'm not sure what php runner is, but to recognize valid PhpUnit, NetBeans run command "phpunit --version", so check what this command gives you in console.
Once I had problem with this, so I simply found the code of phpunit that is responsible for "phpunit --version" and manually type what should be printed when this command is executed. So NetBeans "saw" correct version and everybody is happy :)
I solved the phpunit problem (too old phpunit message on netbeans)
First open terminal and then:
cd /private/etc
cp php.ini.default php.ini
open php.ini file
change include_path to include_path = ".:/usr/share/pear"
Problem solved :)
If however the problem is not solved then try install netbeans for php from netbeans.org
Mate, that is error by Netbeans (see bug id 188240), and it looks like it is not fixed yet. It happens on Mac OSX.
What i did is to rename Application/NetBeans/NetBeans 7.1.1 to Application/NetBeans/NetBeans7.1.1 (note the lack of space)
as per Xdebug, read this:
http://xdebug.org/find-binary.php
when you get the version for your server, add these lines into your php.ini:
zend_extension = /opt/local/lib/php/extensions/<name of your extension>/xdebug.so
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
replacing <name of your extension> with, of course, the name of your extension :)
after this you should be ready to go.
Issue about version soved by reinstalling everything, however I now get this
PHPUnit 3.6.7 by Sebastian Bergmann.
The Xdebug extension is not loaded. No code coverage will be generated.
Cannot open file "/Applications/NetBeans/NetBeans".
How could I load Xdebug? Is that in php.ini or apache conf? or is that in NetBeans?