Composer and most other autoloaders use the standard PHP spl_register_autoload()
function to keep track of the autoloading stack. This combined with the rules of PSR-0 and PSR-4 allow every registered autoloader a chance to fulfill a dependency for your code.
So when you have two autoloaders that can fulfill the same dependency, whichever one gets a chance to respond first wins. To help with this, spl_register_autoload
provides a way to prepend autoloaders to the stack so that they run first. With composer this actually happens by default, the way to disable it so that the you can load the core versions of the dependency is to set prepend-autoloader
to false
in your package's composer.json
.
{
"prepend-autoloader": false
}
Another option entirely is to define provide
in your packages composer.json
with proper versions for the dependencies that the core provides (you can find this in concrete/composer.lock
).
{
"provide": {
"doctrine/dbal": "v2.5.1",
"doctrine/orm": "v2.4.8"
}
}
This will prevent composer from pulling down duplicate versions of dependencies, the downside to this is that you'll need to keep this list up to date manually when the core updates its dependencies.