Improvements to autoload docs

main
Jordi Boggiano 12 years ago
parent fb0d89cce5
commit 939c745a9a

@ -215,21 +215,26 @@ Example:
Autoload mapping for a PHP autoloader. Autoload mapping for a PHP autoloader.
Currently [PSR-0](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md) Currently [PSR-0](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md)
autoloading and classmap generation are supported. autoloading and classmap generation are supported. PSR-0 is the recommended way though
since it offers greater flexibility (no need to regenerate the autoloader when you add
classes).
Under the `psr-0` key you define a mapping from namespaces to paths, relative to the Under the `psr-0` key you define a mapping from namespaces to paths, relative to the
package root. package root. Note that this also supports the PEAR-style convention.
Example: Example:
{ {
"autoload": { "autoload": {
"psr-0": { "Monolog": "src/" } "psr-0": {
"Monolog": "src/",
"Vendor\\Namespace": "src/",
"Pear_Style": "src/"
}
} }
} }
Optional, but it is highly recommended that you follow PSR-0 and use this. If you need to search for a same prefix in multiple directories,
If you need to search for a same namespace prefix in multiple directories,
you can specify them as an array as such: you can specify them as an array as such:
{ {
@ -238,15 +243,24 @@ you can specify them as an array as such:
} }
} }
If you want to have a fallback directory where any namespace can be, you can
use an empty prefix like:
{
"autoload": {
"psr-0": { "": "src/" }
}
}
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 or files
to search for classes. to search for classes.
Example: Example:
{ {
"autoload: { "autoload: {
"classmap": ["src/", "lib/"] "classmap": ["src/", "lib/", "Something.php"]
} }
} }

Loading…
Cancel
Save