Autoloading


Description


The ClassLoader class handles autoloading of classes in the Mako framework. The autoloader will also autoload PSR-0 compatible classes located in the libraries directory as well as classes from third party libraries installed using composer.


Methods


mapClass(string $className, string $classPath)


The mapClass method will add a class to the autoloader mappings.


ClassLoader::mapClass('FooBar', '/path/to/FooBar.php');

ClassLoader::mapClass('foo\FooBar', '/path/to/foo/FooBar.php');

mapClasses(array $classes)


The mapClasses method will add an array of classes to the autoloader mappings.


ClassLoader::mapClasses(array
(
	'Foo' => '/path/to/Foo.php',
	'Bar' => '/path/to/Bar.php',
));

directory(string $path)


The directory method will add an additional path from which the autoloader will try to load PSR-0 compatible classes.


ClassLoader::directory('/path/to/library');

registerNamespace(string $namespace, string $path)


The registerNamespace method allows you to register a PSR-0 compatible namespace with the autoloader.


ClassLoader::registerNamespace('Zend\XmlRpc', MAKO_LIBRARIES_PATH . '/XmlRpc');