I was happily working away in my development environment and suddenly I started getting the following error:
PHP Fatal error: Cannot redeclare composerRequire7a368ac394ae1d2e857becf2a235ebaa() (previously declared in [APP_ROOT]/vendor/composer/autoload_real.php:56) in [APP_ROOT]/vendor/composer/autoload_real.php on line 59
I haven't made any changes to speak of in composer dependencies (although I think I did do a composer update
somewhere in that timeframe but no changes to the dependencies/packages used so nothing big should have changed.
Notably, when I checkout the repo on my laptop I do NOT get this error but if I git clone
a clean repo and then composer install
on my main development machine I DO get this error. So I'm assuming it must have some machine-specific origin but I'm running out of ideas on what that might be.
Any help would be greatly appreciated.
Note: I'm running PHP 5.3.28 on OSX; my app uses namespacing and is PSR0 compliant
Also of note is that I'm running PHPUnit 4.0.17 and the error is triggered at the very first stages of trying to run a unit test (it doesn't matter WHICH unit test). Here's the stack trace:
0.0009 636648 1. {main}() [APP_BASE]/vendor/phpunit/phpunit/phpunit:0 0.0465 1423664 2. PHPUnit_TextUI_Command::main() [APP_BASE]/vendor/phpunit/phpunit/phpunit:54 0.0465 1424280 3. PHPUnit_TextUI_Command->run() [APP_BASE]/vendor/phpunit/phpunit/src/TextUI/Command.php:132 0.0465 1424280 4. PHPUnit_TextUI_Command->handleArguments() [APP_BASE]/vendor/phpunit/phpunit/src/TextUI/Command.php:141 0.0674 2123344 5. PHPUnit_TextUI_Command->handleBootstrap() [APP_BASE]/vendor/phpunit/phpunit/src/TextUI/Command.php:638 0.0681 2139872 6. PHPUnit_Util_Fileloader::checkAndLoad() [APP_BASE]/vendor/phpunit/phpunit/src/TextUI/Command.php:808 0.0681 2140008 7. PHPUnit_Util_Fileloader::load() [APP_BASE]/vendor/phpunit/phpunit/src/Util/Fileloader.php:77 0.0774 2144176 8. include_once('[APP_BASE]/tests/test-loader.php') [APP_BASE]/vendor/phpunit/phpunit/src/Util/Fileloader.php:93 0.0775 2146736 9. include('[APP_BASE]/vendor/autoload.php') [APP_BASE]/tests/test-loader.php:2
Delete composer.lock
and vendor/
and run composer update
again.
I had this problem when I made a copy of an existing project directory and tried to run phpunit on the new directory. Finally figured out that when I executed phpunit, it was running out of the old directory. I ran this:
which phpunit
And saw that it was running from my composer vendor directory:
/home/vagrant/Code/MYOLDPROJECT/api/vendor/bin/phpunit
I ran phpunit from the new directory and the problem disappeared:
/home/vagrant/Code/mynewproject/api/vendor/bin/phpunit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With