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.json

I 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

thehong’s picture

Issue summary: View changes
nick_vh’s picture

Project: Composer » Composer Manager
Version: 8.x-1.x-dev » 7.x-2.x-dev

Having 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 :)

nick_vh’s picture

Just upgraded my composer version. It looks like the psr-4 autoloader is not included in the general autoload.php file. Investigating

nick.veenhof@MacBookAir-NickVeenhof:~/Sites/dev/drupal7dev/site$ composer --version
Composer version 1.0.0-alpha8 2014-01-06 18:39:59
nick.veenhof@MacBookAir-NickVeenhof:~/Sites/dev/drupal7dev/site$ composer self-update
Updating to version 08e34858d64740f74c5c5a6fa22b425ef12d6e3e.
    Downloading: 100%         
Use composer self-update --rollback to return to version 1.0.0-alpha8
nick.veenhof@MacBookAir-NickVeenhof:~/Sites/dev/drupal7dev/site$ composer --version
Composer version 08e34858d64740f74c5c5a6fa22b425ef12d6e3e 2014-06-05 09:14:29

thehong’s picture

Issue summary: View changes
nick_vh’s picture

Version: 7.x-2.x-dev » 7.x-1.x-dev
Issue summary: View changes

So there still seems to be a conflict

nick.veenhof@MacBookAir-NickVeenhof:~/Sites/dev/drupal7dev/site/sites/default/files/composer$ drush composer-manager --version 
Composer version 6f8b2579971414a3e09d615149791759fe06ac02
nick.veenhof@MacBookAir-NickVeenhof:~/Sites/dev/drupal7dev/site/sites/default/files/composer$ composer --version 
Composer version 08e34858d64740f74c5c5a6fa22b425ef12d6e3e 2014-06-05 09:14:29

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.

nick_vh’s picture

Updated the composer project now:

drush dl composer-8.x-1.x

Ran 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.

cpliakas’s picture

Status: Active » Closed (won't fix)

Thanks 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!