Autoloader class
Framework\Autoload\Autoloader
Class Autoloader.
The Autoloader class allows to set namespace directories to search for files
(PSR4) and set the absolute path of classes without namespaces (PSR0).
Defined in libraries/autoload/src/Autoloader.php
Properties #
- $classes
- List of classes to file paths.
- $namespaces
- List of namespaces to directory paths.
- $debugCollector
- -
$classes
List of classes to file paths.
$namespaces
List of namespaces to directory paths.
$debugCollector
Methods #
- __construct()
- Autoloader constructor.
- addNamespace()
- Adds directory paths to a namespace.
- addNamespaces()
- Adds directory paths to namespaces.
- findClassPath()
- Finds the file path of a class searching in the class mapping and resolving namespaces.
- getClass()
- Gets a class file path.
- getClasses()
- Gets all mapped classes.
- getDebugCollector()
- -
- getNamespace()
- Gets the directory paths for a given namespace.
- getNamespaces()
- Gets all mapped namespaces.
- loadClass()
- Loads a class file.
- register()
- Registers the Autoloader::loadClass() as autoload implementation.
- removeClass()
- Removes one class from the mapping.
- removeClasses()
- Removes classes from the mapping.
- removeNamespace()
- Removes one namespace from the mapping.
- removeNamespaces()
- Removes namespaces from the mapping.
- setClass()
- Sets one class mapping for a file path.
- setClasses()
- Sets classes mapping for file paths.
- setDebugCollector()
- -
- setNamespace()
- Sets one namespace mapping for a directory path.
- setNamespaces()
- Sets namespaces mapping for directory paths.
- unregister()
- Unregisters the Autoloader::loadClass() as autoload implementation.
- loadClassFile()
- -
- loadDebug()
- -
- makeRenderedDirectoryPaths()
- -
- renderDirectoryPath()
- Gets the canonicalized absolute pathname for a directory path.
- renderFilePath()
- Renders the canonicalized absolute pathname for a file path.
- renderRealName()
- Renders a class or namespace name without lateral slashes.
- sortNamespaces()
- -
__construct()
Autoloader constructor.
- bool $register - Register the Autoloader::loadClass() as autoload implementation
- string $extensions - A comma delimited list of file extensions for spl_autoload
addNamespace()
Adds directory paths to a namespace.
- string $namespace - Namespace name
- array|string $dir - Directory path
addNamespaces()
Adds directory paths to namespaces.
- array $namespaces - Namespace names as keys and directory paths as values
findClassPath()
Finds the file path of a class searching in the class mapping and resolving namespaces.
- string $class - Fully qualified class name (with namespace)
getClass()
Gets a class file path.
- string $name - Fully qualified class name (with namespace)
getClasses()
Gets all mapped classes.
getDebugCollector()
getNamespace()
Gets the directory paths for a given namespace.
- string $name - Namespace name
getNamespaces()
Gets all mapped namespaces.
loadClass()
Loads a class file.
- string $class - Fully qualified class name (with namespace)
register()
Registers the Autoloader::loadClass() as autoload implementation.
- string $extensions - A comma delimited list of file extensions for spl_autoload
removeClass()
Removes one class from the mapping.
- string $name - Fully qualified class name (with namespace)
removeClasses()
Removes classes from the mapping.
- array $names - List of class names
removeNamespace()
Removes one namespace from the mapping.
- string $name - Namespace name
removeNamespaces()
Removes namespaces from the mapping.
- array $names - List of namespace names
setClass()
Sets one class mapping for a file path.
- string $name - Fully qualified class name (with namespace)
- string $filepath - Class file path
setClasses()
Sets classes mapping for file paths.
- array $classes - Associative array with class names as keys and file paths as values
setDebugCollector()
- ?\Framework\Autoload\Debug\AutoloadCollector $debugCollector
- string $name
setNamespace()
Sets one namespace mapping for a directory path.
- string $namespace - Namespace name
- array|string $dir - Directory path
setNamespaces()
Sets namespaces mapping for directory paths.
- array $namespaces - Namespace names as keys and directory paths as values
unregister()
Unregisters the Autoloader::loadClass() as autoload implementation.
loadClassFile()
- string $class
loadDebug()
- string $class
makeRenderedDirectoryPaths()
- array $directories
renderDirectoryPath()
Gets the canonicalized absolute pathname for a directory path.
Adds a trailing slash.
- string $path
renderFilePath()
Renders the canonicalized absolute pathname for a file path.
- string $path - File path
renderRealName()
Renders a class or namespace name without lateral slashes.
- string $name - Class or namespace name