composer/composer — Issue #207: Wrapping the autoloader definition in class_exists
Author: stof
Created: 2012-01-15 17:50:00+00:00
State: open

I think the class definition should be wrapped in a class_exists check in the generated autoload file. This would allow loading several autoload files without having a fatal error.

Behat currently uses a hack to avoid issues about similar class names when including the autoload file in the phar: https://github.com/Behat/Behat/blob/master/src/Behat/Behat/Compiler/PharCompiler.php#L74

currently, it does not do it for Mink or for the behat pear package, meaning it will break things in such cases. See https://groups.google.com/forum/#!topic/behat/aSTSWEv_GvM for a report /cc @everzet

I think Composer should handle it instead of requiring more hacky workaround in libraries using its autoload mecanism for their other distribution channels (the installation through composer works fine for behat as there will be a single autoloader in such case)

Btw, I see a possible issue even when using composer for the installation: let think you installed Behat in some global place and use it to test an app which uses composer itself. you will load 2 composer-generated files: the file of the global installation and the file of the project.