问题
Running:
- MAMP 2.0.5
- PHP 5.3.6 (bundled with MAMP)
- Mac OS X Lion 10.7.2
My goal is to get the Codeception testing framework to work and use within my MAMP project. I'm following the instructions here on how to install it.
Pear is installed and working fine. I am able to get Codeception installed with these commands:
$ pear channel-discover codeception.com/pear
$ pear install codeception/Codeception
Once installed when I try to run the codecept commands I get the following error:
Warning: require_once(Codeception/autoload.php): failed to open stream: No such file or directory in /usr/bin/codecept on line 12
Fatal error: require_once(): Failed opening required 'Codeception/autoload.php' (include_path='.:') in /usr/bin/codecept on line 12
I think that the issue is caused by either:
- A conflict between MAMP's PHP installation in the one bundled with OS X
- An issue with the include_path in my php.ini or somewhere else
Also of interest
- When I run the
$ phpunit
command from inside my project folder I get-bash: phpunit: command not found
but if I run it as$ /Applications/MAMP/bin/php/php5.3.6/bin/phpu nit
it works just fine. - I would expect there to be a
codecept
file in/Applications/MAMP/bin/php/php5.3.6/bin/
but there isn't - there is however aCodeception
folder in/Applications/MAMP/bin/php/php5.3.6/lib/php
- I've tried a few different ways to install it, and I guess one of the ways installed Codeception in Lion's copy of php (as opposed to MAMP's) - so I do have a
codecept
file in/usr/bin/
as well as theCodeception
folder in/usr/lib/php/pear/
For reference:
- PHP lives here:
/Applications/MAMP/bin/php/php5.3.6/bin/php
- Pear lives here:
/Applications/MAMP/bin/php/php5.3.6/bin/pear
- PHPUnit lives here:
/Applications/MAMP/bin/php/php5.3.6/bin/phpunit
Any Help? Suggestions?
Thanks to Davert's help - I was able to confirm that this is a conflict with MAMP's copy of PHP and Lion's built-in copy of PHP. To solve the issue I created a new php.ini
file in /etc
that was a duplicate of php.ini.default
and changed the include_path
to /Applications/MAMP/bin/php/php5.3.6/lib/php
回答1:
I think the problem is: your PEAR command was executed from bundled PHP. So your primary MAMP PHP libraries in (/Applications/MAMP/bin/php/php5.3.6/bin/pear)
were not updated. I suggest you should find the second PEAR were the Codeception was exctually stored. And add path to it into 'include_path' in php.ini.
Yes, PEAR is quite buggy. In next releases a Composer installator will be added.
Also, you can try to use Phar executable.
In this case a Codeception should be executed with:
php codecept.phar
回答2:
One solution that worked for me was to edit /Applications/MAMP/bin/php5.3/bin/codecept and replace /usr/bin/php at the first line by /Applications/MAMP/bin/php5.3/bin/php
来源:https://stackoverflow.com/questions/8995633/getting-codeception-phpunit-working-on-mamp-with-os-x-lion