$prefixes
$prefixes : array
Stores namespaces as key, and path as values.
CodeIgniter Autoloader
An autoloader that uses both PSR4 autoloading, and traditional classmaps.
Given a foo-bar package of classes in the file system at the following paths:
/path/to/packages/foo-bar/
/src
Baz.php # Foo\Bar\Baz
Qux/
Quux.php # Foo\Bar\Qux\Quux
you can add the path to the configuration array that is passed in the constructor. The Config array consists of 2 primary keys, both of which are associative arrays: 'psr4', and 'classmap'.
$Config = [
'psr4' => [
'Foo\Bar' => '/path/to/packages/foo-bar'
],
'classmap' => [
'MyClass' => '/path/to/class/file.php'
]
];
Example:
<?php
// our configuration array
$Config = [ ... ];
$loader = new \CodeIgniter\Autoloader\Autoloader($Config);
// register the autoloader
$loader->register();
initialize(\Config\Autoload $config, \Config\Modules $moduleConfig) : $this
Reads in the configuration array (described above) and stores the valid parts that we'll need.
\Config\Autoload | $config | |
\Config\Modules | $moduleConfig |
addNamespace(array|string $namespace, string $path = null) : \CodeIgniter\Autoloader\Autoloader
Registers namespaces with the autoloader.
array|string | $namespace | |
string | $path |
removeNamespace(string $namespace) : \CodeIgniter\Autoloader\Autoloader
Removes a single namespace from the psr4 settings.
string | $namespace |
sanitizeFilename(string $filename) : string
Sanitizes a filename, replacing spaces with dashes.
Removes special characters that are illegal in filenames on certain operating systems and special characters requiring special escaping to manipulate at the command line. Replaces spaces and consecutive dashes with a single dash. Trim period, dash and underscore from beginning and end of filename.
string | $filename |
The sanitized filename
loadLegacy(string $class) : mixed
Attempts to load the class from common locations in previous version of CodeIgniter, namely 'app/Libraries', and 'app/Models'.
string | $class | The class name. This typically should NOT have a namespace. |
The mapped file name on success, or boolean false on failure
Loading…