Add support for mapping a namespace prefix onto many dirs in the autoload config
parent
f7affa21b0
commit
30cfb69739
|
@ -204,6 +204,14 @@ Example:
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional, but it is highly recommended that you follow PSR-0 and use this.
|
Optional, but it is highly recommended that you follow PSR-0 and use this.
|
||||||
|
If you need to search for a same namespace prefix in multiple directories,
|
||||||
|
you can specify them as an array as such:
|
||||||
|
|
||||||
|
{
|
||||||
|
"autoload": {
|
||||||
|
"psr-0": { "Monolog": ["src/", "lib/"] }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
You can use the classmap generation support to define autoloading for all libraries
|
You can use the classmap generation support to define autoloading for all libraries
|
||||||
that do not follow "PSR-0". To configure this you specify all directories
|
that do not follow "PSR-0". To configure this you specify all directories
|
||||||
|
|
|
@ -125,7 +125,7 @@
|
||||||
"properties": {
|
"properties": {
|
||||||
"psr-0": {
|
"psr-0": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"description": "This is a hash of namespaces (keys) and the directories they can be found into (values) by the autoloader.",
|
"description": "This is a hash of namespaces (keys) and the directories they can be found into (values, can be arrays of paths) by the autoloader.",
|
||||||
"additionalProperties": true
|
"additionalProperties": true
|
||||||
},
|
},
|
||||||
"classmap": {
|
"classmap": {
|
||||||
|
|
|
@ -172,11 +172,12 @@ EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($package->getAutoload() as $type => $mapping) {
|
foreach ($package->getAutoload() as $type => $mapping) {
|
||||||
foreach ($mapping as $namespace => $path) {
|
foreach ($mapping as $namespace => $paths) {
|
||||||
$autoloads[$type][$namespace][] = empty($installPath) ? $path : $installPath.'/'.$path;
|
foreach ((array) $paths as $path) {
|
||||||
|
$autoloads[$type][$namespace][] = empty($installPath) ? $path : $installPath.'/'.$path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($autoloads as $type => $maps) {
|
foreach ($autoloads as $type => $maps) {
|
||||||
|
|
|
@ -77,7 +77,7 @@ class AutoloadGeneratorTest extends TestCase
|
||||||
{
|
{
|
||||||
$package = new MemoryPackage('a', '1.0', '1.0');
|
$package = new MemoryPackage('a', '1.0', '1.0');
|
||||||
$package->setAutoload(array(
|
$package->setAutoload(array(
|
||||||
'psr-0' => array('Main' => 'src/', 'Lala' => 'src/'),
|
'psr-0' => array('Main' => 'src/', 'Lala' => array('src/', 'lib/')),
|
||||||
'classmap' => array('.composersrc/'),
|
'classmap' => array('.composersrc/'),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
|
@ -7,5 +7,5 @@ $baseDir = dirname($vendorDir);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'Main' => $baseDir . '/src/',
|
'Main' => $baseDir . '/src/',
|
||||||
'Lala' => $baseDir . '/src/',
|
'Lala' => array($baseDir . '/src/', $baseDir . '/lib/'),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue