Monolog is using PSR-4 autoloader. I install it using this command:
$ drush composer-manager require monolog/monolog
Please provide a version constraint for the monolog/monolog requirement: *
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing psr/log (dev-master a78d650)
Cloning a78d6504ff5d4367497785ab2ade91db3a9fbe11
- Installing monolog/monolog (dev-master 467e30a)
Cloning 467e30a9c9fa22395608cc515cd45a60ecc84c4e
…
Writing lock file
Generating autoload files
But when I look into the vendor/composer/, there is no autoload_psr4.php file:
$ ll ../all/vendor/composer/
drwxrwxr-x 2 root root 4.0K May 3 05:36 .
drwxrwxr-x 11 root root 4.0K May 3 05:37 ..
-rw-rw-r-- 1 root root 6.8K May 3 05:37 ClassLoader.php
-rw-rw-r-- 1 root root 193 May 3 05:37 autoload_classmap.php
-rw-rw-r-- 1 root root 340 May 3 05:37 autoload_files.php
-rw-rw-r-- 1 root root 620 May 3 05:37 autoload_namespaces.php
-rw-rw-r-- 1 root root 1.4K May 3 05:37 autoload_real.php
-rw-rw-r-- 1 root root 17K May 3 05:37 installed.jsonI also tried with /devel/php, no classes under Monolog can be autoloaded:
dsm(array(
class_exists('Monolog\Logger'),
class_exists('Monolog\Handler\StreamHandler'),
));
For now, to make it works, I run `drush composer-json-rebuild`, then `cd files/composer` and then, `composer update`.
Comments
Comment #1
thehong commentedComment #2
nick_vhHaving the exact same problem and I was able to reproduce. Biggest problem is that is does not generate autoload_psr4.php when running composer-manager update.
Going in the files/composer directory and run composer update does resolve it. Not sure why this would be the case, but something's fishy :)
Comment #3
nick_vhJust upgraded my composer version. It looks like the psr-4 autoloader is not included in the general autoload.php file. Investigating
Comment #4
thehong commentedComment #6
nick_vhSo there still seems to be a conflict
When I run composer update on the sites/default/files folder it generates the correct autoload files now.
Let's see which composer the composer-manager of drush tries to invoke.
Comment #7
nick_vhUpdated the composer project now:
drush dl composer-8.x-1.xRan drush composer-manager update after deleting the vendor dir and my composer.json and composer.lock files and BAM! Things are working :) - there should probably be some warning in composer-manager is that the composer version you are using is too old to support PSR-4. For some reason the composer project is using a different version of composer versus your system wide composer version.
Comment #8
cpliakas commentedThanks for reporting.
To provide some context, Composer Manager uses the Composer Drush component to execute Composer commands. See #1943618: Use Drush Composer if available in the Drush command.
As Nick_vh mentioned, the extension uses a native copy of Composer where you have to update the extension to update the composer library. The version of Composer is important because it added PSR-4 support only within the last few months.
I am respectfully closing as "won't fix" because it seems to me this is out of Composer Manager's realm, however I am happy to facilitate a better developer experience in Composer Manager if there is something specific we can do and someone is interested in contributing the enhancement. If so, please open a new issue.
Thanks for reporting and debugging!