-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Call to undefined method Composer\Autoload\ClassLoader::setPsr4() #2553
Comments
PHPUnit's classloader is loaded before the local one and the class is outdated there it seems, so you should do a |
Sorry to drag this back up again, but I'm having a similar issue and running
Obviously I tried running
|
The ambiguous command issue is a regression in symfony that's been fixed already, it will be in composer as soon as they release. The rest, it looks like whatever autoloader phpunit uses is still the old one, maybe it wasn't installed with |
Oh, right. I was using my personal installation of PHPUnit instead of the one required by composer, which does work. I should have thought of that. Thanks. |
@Seldaek sorry to dig it up, but also have this problem: loostro@Skipper:~/Projekty/prognozy$ phpunit -c app
PHP Fatal error: Call to undefined method Composer\Autoload\ClassLoader::setPsr4() in /home/loostro/Projekty/prognozy/vendor/composer/autoload_real.php on line 33
PHP Stack trace:
PHP 1. {main}() /usr/local/lib/phpunit/vendor/phpunit/phpunit/composer/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/local/lib/phpunit/vendor/phpunit/phpunit/composer/bin/phpunit:63
PHP 3. PHPUnit_TextUI_Command->run() /usr/local/lib/phpunit/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:129
PHP 4. PHPUnit_TextUI_Command->handleArguments() /usr/local/lib/phpunit/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:138
PHP 5. PHPUnit_TextUI_Command->handleBootstrap() /usr/local/lib/phpunit/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:606
PHP 6. PHPUnit_Util_Fileloader::checkAndLoad() /usr/local/lib/phpunit/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:778
PHP 7. PHPUnit_Util_Fileloader::load() /usr/local/lib/phpunit/vendor/phpunit/phpunit/PHPUnit/Util/Fileloader.php:76
PHP 8. include_once() /usr/local/lib/phpunit/vendor/phpunit/phpunit/PHPUnit/Util/Fileloader.php:92
PHP 9. require_once() /home/loostro/Projekty/prognozy/app/bootstrap.php.cache:3
PHP 10. require() /home/loostro/Projekty/prognozy/app/autoload.php:5
PHP 11. ComposerAutoloaderInit0fd3c5178a91b0785080bdcaf7c37958::getLoader() /home/loostro/Projekty/prognozy/vendor/autoload.php:7 Then I googled and found this issue, however it didn't help: loostro@Skipper:~/Projekty/prognozy$ composer global dump
Changed current directory to /home/loostro/.composer
Composer could not find a composer.json file in /home/loostro/.composer
To initialize a project, please create a composer.json file as described in the http://getcomposer.org/ "Getting Started" section I've got composer installed globally. The loostro@Skipper:~/Projekty/prognozy$ ls -l
razem 256
drwxr-x--- 6 loostro www-data 4096 maj 6 01:56 app
drwxrwxr-x 7 loostro loostro 4096 maj 6 00:01 assets
drwxr-x--- 2 loostro www-data 4096 maj 6 01:21 bin
-rwxrwxr-x 1 loostro loostro 3569 maj 19 17:44 composer.json
-rw-rw-r-- 1 loostro loostro 166441 maj 6 01:56 composer.lock
drwxr-x--- 13 loostro www-data 4096 maj 5 23:12 web
drwxr-x--- 3 loostro www-data 4096 sty 10 16:04 src
drwxr-x--- 40 loostro www-data 4096 maj 6 01:56 vendor (removed the text files from the list for brevity) What's wrong? Any ideas how to fix this? |
well, your phpunit is installed in |
Thanks @stof ! Indeed going to |
I am seeing the same error on WordPress. I realized that on the app having plugin system like WordPress, different plugins could autoload different Composer autoloader under their vendor/composer directories,and if the first-loaded one is using rather old autoloader (which did not support psr4), the latter one (likely set-up with newer Composer) cause this error. I have not found the solution yet, just record this here for someone will see the same issue. |
I was trying to do a test PSR4 package for myself, I have the latest version of Composer. However after running
composer install
with the following autoload directive :When including
vendor/autoload.php
I'm getting the following error :Tried doing
composer self-update
but nothing :Am I doing something wrong or ? I checked the
vendor/composer/ClassLoader.php
class and it does have asetPsr4
method which is even weirder.The text was updated successfully, but these errors were encountered: