In Phalcon you can register namespaces, prefixes, directories or classes by loader class. Below are sample usage for same.
Registering namespaces/prefixes in Phalcon
use Phalcon\Loader;
$loader = new Loader();
// Register some namespaces
$loader->registerNamespaces(
[
"Example\Base" => "vendor/example/base/",
"Example\Adapter" => "vendor/example/adapter/",
"Example" => "vendor/example/",
]
);
// Register autoloader
$loader->register();
Registering directories in Phalcon
use Phalcon\Loader;
// Creates the autoloader
$loader = new Loader();
// Register some directories
$loader->registerDirs(
[
"library/MyComponent/",
"library/OtherComponent/Other/",
"vendor/example/adapters/",
"vendor/example/",
]
);
// Register autoloader
$loader->register();
Registering classes in Phalcon
use Phalcon\Loader;
// Creates the autoloader
$loader = new Loader();
// Register some classes
$loader->registerClasses(
[
"Some" => "library/OtherComponent/Other/Some.php",
"Example\Base" => "vendor/example/adapters/Example/BaseClass.php",
]
);
// Register autoloader
$loader->register();