Reputation: 331
I am getting this error while i tried to run testclass in phpunit.
C:\xampp\htdocs\unittest>phpunit UnitTest usertest.php
PHP Warning: require_once(File/Iterator/Autoload.php): failed to open stream No such file or directory in C:\xampp\php\pear\PHPUnit\Autoload.php on line 45
PHP Stack trace:
PHP 1. {main}() C:\xampp\php\phpunit:0
PHP 2. require() C:\xampp\php\phpunit:41
Warning: require_once(File/Iterator/Autoload.php): failed to open stream: No such file or directory in C:\xampp\php\pear\PHPUnit\Autoload.php on line 45
Call Stack:
0.0004 325352 1. {main}() C:\xampp\php\phpunit:0
0.0026 366520 2. require('C:\xampp\php\pear\PHPUnit\Autoload.php')xampp\php\phpunit:41
PHP Fatal error: require_once(): Failed opening required 'File/Iterator/Autoload.php' (include_path='.;C:\php\pear') in C:\xampp\php\pear\PHPUnit\Autoload.php on line 45
PHP Stack trace:
PHP 1. {main}() C:\xampp\php\phpunit:0'
could anyone give solution to this ??
Note: i am using windows 7.
Thanks,
Upvotes: 27
Views: 29887
Reputation: 661
Look at the error:
(include_path='.;C:\php\pear') in C:\xampp\php\pear\PHPUnit\Autoload.php
The Xampp is trying to locate that file in include_path .;C:\php\pear
But The path for the pear is .;C:\xampp\php\pear
.
Set the right path for the pear and it will work. I just made it.
Upvotes: 0
Reputation: 1
I had the same issue with windows 7 and xampp(php 5.6.11), I tried all reinstalling pear and phpunit but it didn't work. When I checked the permission of the C:\xammp\php\pear directory it was read-only, After I changed the permission it started working.
Upvotes: 0
Reputation: 134
I am using Ubuntu 14.04 and I installed phpunit via Ubuntu Software Center which didn't work.
Finally I remove it and I followed instructions from here
wget https://phar.phpunit.de/phpunit.phar
chmod +x phpunit.phar
sudo mv phpunit.phar /usr/local/bin/phpunit
Upvotes: 1
Reputation: 479
Also, using open-server bundle one can notice that it reports way too short include_path.
To fix this on Windows 7 you can do
cd c:\Windows
mklink php.ini c:\OpenServer\userdata\temp\config\php.ini
Upvotes: 0
Reputation: 777
All kind of nice things I have read on this one. First check where the Autoload.php is located. Use:
$ find . -name 'Autoload.php' -type f
I assume that your files are located in:
/usr/local/pear/share/pear
I have Apple OSX 10.8.4 MAMP and MAMP-PRO installed and I have several other PHP installations.
For the last one I have done the following:
First check if there is a php.ini in the directory:
/private/etc
If not, do:
$ sudo cp /private/etc/php.ini.default /private/etc/php.ini
Add the following lines at the bottom of the 'php.ini' file:
; *** Added by <your-name> ****
include_path=".:/usr/local/pear/share/pear"
; *** Ended addition ****
Done.
Upvotes: 3
Reputation: 1604
Checking pear config helped me find this quicky:
bash-3.2# pear config-show | grep php_dir
PEAR directory php_dir /usr/local/pear/share/pear
bash-3.2# vi /etc/php.ini
include_path = ".:/php/includes:/usr/local/pear/share/pear"
Upvotes: 7
Reputation: 1237
I had the same problem using PhP 5.3 on OSX 10.6 using the built-in server configuration.
I noticed that while PHPUnit was being successfully installed to /usr/lib/php, Autoload.php was trying (line 45) to load the File Iterator from its current directory (/usr/lib/php/PHPUnit) rather than the directory Pear was installing it to (/usr/lib/php/File). Could this be a bug in the Pear installer?
A simple ln -s /usr/lib/php/File /usr/lib/php/PHPUnit/File solved the problem.
Upvotes: 2
Reputation: 31
For me the fix was simple (Ubuntu 12.04). First I did a search to make sure the file existed and where it was located:
locate Autoload.php
Which should return results similar to this:
/usr/share/php/File/Iterator/Autoload.php
/usr/share/php/PHP/CodeCoverage/Autoload.php
/usr/share/php/PHP/Depend/Autoload.php
/usr/share/php/PHP/Invoker/Autoload.php
/usr/share/php/PHP/Timer/Autoload.php
/usr/share/php/PHP/Token/Stream/Autoload.php
/usr/share/php/PHPCPD/Autoload.php
/usr/share/php/PHPUnit/Autoload.php
/usr/share/php/PHPUnit/Framework/MockObject/Autoload.php
/usr/share/php/PHP_CodeBrowser/Autoload.php
/usr/share/php/Text/Template/Autoload.php
Then I checked my include_path, which was set correctly in /etc/php5/apache2/php.ini, but was still commented out in /etc/php5/cli/php.ini (the command line interface).
Uncommenting this line worked for me:
include_path = ".:/usr/share/php:/usr/include/php5"
Pretty basic I know, but it's always the little things when setting up a new machine ;-)
Upvotes: 3
Reputation: 41
After 2 days of post reading, finally i've solved with guides:
Clean pc by hold/corrupted installation of Phpunit LINK
and reinstalled with this guide LINK
Upvotes: 4
Reputation: 231
A possible reason that this might happen is that your php include_path is not set correctly. Please make sure you have the appropriate path to PEAR available. For my WAMP installation it would be:
include_path=".;C:\wamp\bin\php\php5.3.8\PEAR\PEAR"
However, it will most likely be different on your system.
A side note, you will want to update both your apache php.ini, as well as your php.ini located in your PHP installation folder. CLI the default php.ini, and web requests (and often times other software that you might be using PEAR packages for) will use the apache php.ini.
Hope this helps.
Upvotes: 23
Reputation: 38961
Your phpunit installation is broken. The easiest fix for this is
pear install --force --alldeps phpunit/phpunit
and see if what worked out.
You will need the most current pear version 1.9.4
. If you don't have that version install it using the go-pear.phar
. If you are running from xammp for something don't try to fix the pear installation they ship. Usually it's a LOT easier to reinstall it.
If you want to you can try to just install the missing package too:
pear install phpunit/File_Iterator
(add a --force
if pear tells you that it is already installed)
Upvotes: 10