Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
After install Composer Manager module I get next fatal error.
Fatal error: Call to undefined method Composer\Autoload\ClassLoader::setPsr4() in .../sites/all/vendor/composer/autoload_real.php on line 36
Comments
Comment #1
danylevskyiI have Currency module installed. It defines it's
composer.json
file and storesvendor
directory inside module's directory. The problem was in outdated autoloader. I've update it and all worked great.Thanks for the great module!
Comment #2
basvredelingI can't believe I spent 2 days trying to fix the autoloader of another module while all along it was currency!
Thanks for the suggestion.
Comment #3
basvredelingI've asked Xano to add a small paragraph of text to the README.txt of the Currency module.
Also see: #2383825: Possible autoloader clash
Comment #4
dman CreditAttribution: dman as a volunteer and at Sparks Interactive commentedOMG. This took me hours as well - even after reading this issue and having what I thought was a clue.
I've not got currency in action.
In the end it was another drush module that's been using composer (there are quite a few of these around now).
For me it was drush_vagrant being long out of date (I only use it every few months).
Tracing it was really hard.
Its implementation of Classloader at ~/.drush/drush-vagrant/vendor/composer/ClassLoader.php was winning and failing.
This seems to be triggered by the drush module load orders or something, as it was pretty high in the list, being included before the Drupal bootstrap.
I could only trace it in the end by locating the named file vendor/composer/autoload_real.php and inserting some debug just before it died
That list (of way too many PHP files) identified the composer/ClassLoader.php that was the trigger for me.
This is something to do with the way composer in general expectes to be used, and something to do with the way that contrib modules are starting to do their own thing with composer dependencies. Hopefully this is just a transition period until either D7 contribs start using this module (?) or D8 modules start being distributed by composer proper (?)
Noting my diagnostic process here in case it saves the next victim half a day.
Comment #5
puiduThank you! You saved my day! I had the same problem. I updated currency module and all worked fine.