Fabien Potencier 997f354d53 tweaked the README files hace 13 años
..
ApcUniversalClassLoader.php 59301a93d7 [ClassLoader] tweaked public @api hace 14 años
ClassCollectionLoader.php 85ed5c67dc [ClassLoader] Fixed state when trait_exists doesn't exists hace 13 años
DebugUniversalClassLoader.php cf4a91e923 [ClassLoader] fixed usage of trait_exists() hace 13 años
LICENSE f54cedfe5e added LICENSE files for the subtree repositories hace 14 años
MapClassLoader.php cc07af2449 [ClassLoader] replaced MapFileClassLoader by MapClassLoader hace 14 años
README.md 997f354d53 tweaked the README files hace 13 años
UniversalClassLoader.php 7f3b6baf3a [ClassLoader] fixed CS hace 13 años
composer.json d1ae6c7cb6 bumped Symfony version in composer.json files to 2.0.7 hace 13 años

README.md

ClassLoader Component

ClassLoader loads your project classes automatically if they follow some standard PHP conventions.

The Universal ClassLoader is able to autoload classes that implement the PSR-0 standard or the PEAR naming convention.

First, register the autoloader:

require_once __DIR__.'/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';

use Symfony\Component\ClassLoader\UniversalClassLoader;

$loader = new UniversalClassLoader();
$loader->register();

Then, register some namespaces with the registerNamespace() method:

$loader->registerNamespace('Symfony', __DIR__.'/src');
$loader->registerNamespace('Monolog', __DIR__.'/vendor/monolog/src');

The registerNamespace() method takes a namespace prefix and a path where to look for the classes as arguments.

You can also register a sub-namespaces:

$loader->registerNamespace('Doctrine\\Common', __DIR__.'/vendor/doctrine-common/lib');

The order of registration is significant and the first registered namespace takes precedence over later registered one.

You can also register more than one path for a given namespace:

$loader->registerNamespace('Symfony', array(__DIR__.'/src', __DIR__.'/symfony/src'));

Alternatively, you can use the registerNamespaces() method to register more than one namespace at once:

$loader->registerNamespaces(array(
    'Symfony'          => array(__DIR__.'/src', __DIR__.'/symfony/src'),
    'Doctrine\\Common' => __DIR__.'/vendor/doctrine-common/lib',
    'Doctrine'         => __DIR__.'/vendor/doctrine/lib',
    'Monolog'          => __DIR__.'/vendor/monolog/src',
));

For better performance, you can use the APC based version of the universal class loader:

require_once __DIR__.'/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
require_once __DIR__.'/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php';

use Symfony\Component\ClassLoader\ApcUniversalClassLoader;

$loader = new ApcUniversalClassLoader('apc.prefix.');

Furthermore, the component provides tools to aggregate classes into a single file, which is especially useful to improve performance on servers that do not provide byte caches.