Phalcon autoload
NOTE
All classes are prefixed with Phalcon
Autoload\Exception¶
Class Source on GitHub
Exceptions thrown in Phalcon\Autoload will use this class
\ExceptionPhalcon\Autoload\Exception
Autoload\Exceptions\LoaderDirectoriesNotArray¶
Class Source on GitHub
\ExceptionPhalcon\Autoload\ExceptionPhalcon\Autoload\Exceptions\LoaderDirectoriesNotArray
Uses Phalcon\Autoload\Exception
Method Summary¶
Methods¶
__construct()¶
Autoload\Exceptions\LoaderMethodNotCallable¶
Class Source on GitHub
\ExceptionPhalcon\Autoload\ExceptionPhalcon\Autoload\Exceptions\LoaderMethodNotCallable
Uses Phalcon\Autoload\Exception
Method Summary¶
Methods¶
__construct()¶
Autoload\Loader¶
Class Source on GitHub
The Phalcon Autoloader provides an easy way to automatically load classes (namespaced or not) as well as files. It also features extension loading, allowing the user to autoload files with different extensions than .php.
Phalcon\Events\AbstractEventsAwarePhalcon\Autoload\Loader
Uses Phalcon\Autoload\Exceptions\LoaderDirectoriesNotArray · Phalcon\Autoload\Exceptions\LoaderMethodNotCallable · Phalcon\Events\AbstractEventsAware
Method Summary¶
public __construct( bool $isDebug = false ) Loader constructor. public static addClass(string $name,string $file) Adds a class to the internal collection for the mapping public static addDirectory( string $directory ) Adds a directory for the loaded files public static addExtension( string $extension ) Adds an extension for the loaded files public static addFile( string $file ) Adds a file to be added to the loader public static addNamespace(string $name,mixed $directories,bool $prepend = false) public bool autoload( string $className ) Autoloads the registered classes public string|null getCheckedPath() Get the path the loader is checking for a path public array getClasses() Returns the class-map currently registered in the autoloader public array getDebug() Returns debug information collected public array getDirectories() Returns the directories currently registered in the autoloader public array getExtensions() Returns the file extensions registered in the loader public array getFiles() Returns the files currently registered in the autoloader public string|null getFoundPath() Get the path when a class was found public array getNamespaces() Returns the namespaces currently registered in the autoloader public bool isRegistered() returns isRegistered public void loadFiles() Checks if a file exists and then adds the file by doing virtual require public static register( bool $prepend = false ) Register the autoload method public static setClasses(array $classes,bool $merge = false) Register classes and their locations public static setDirectories(array $directories,bool $merge = false) Register directories in which "not found" classes could be found public static setExtensions(array $extensions,bool $merge = false) Sets an array of file extensions that the loader must try in each attempt public static setFileCheckingCallback( mixed $method = null ) Sets the file check callback. public static setFiles(array $files,bool $merge = false) Registers files that are "non-classes" hence need a "require". This is public static setNamespaces(array $namespaces,bool $merge = false) Register namespaces and their related directories public static unregister() Unregister the autoload method protected bool requireFile( string $file ) If the file exists, require it and return true; false otherwise Properties¶
protected string|null $checkedPath = null protected array $classes = [] protected array $debug = [] protected array $directories = [] protected array $extensions = [] protected string|callable $fileCheckingCallback = "is_file" protected array $files = [] protected string|null $foundPath = null protected bool $isDebug = false protected bool $isRegistered = false protected array $namespaces = [] protected int $nestingLevel = 0 Methods¶
__construct()¶
Loader constructor.
addClass()¶
Adds a class to the internal collection for the mapping
addDirectory()¶
Adds a directory for the loaded files
addExtension()¶
Adds an extension for the loaded files
addFile()¶
Adds a file to be added to the loader
addNamespace()¶
autoload()¶
Autoloads the registered classes
getCheckedPath()¶
Get the path the loader is checking for a path
getClasses()¶
Returns the class-map currently registered in the autoloader
getDebug()¶
Returns debug information collected
getDirectories()¶
Returns the directories currently registered in the autoloader
getExtensions()¶
Returns the file extensions registered in the loader
getFiles()¶
Returns the files currently registered in the autoloader
getFoundPath()¶
Get the path when a class was found
getNamespaces()¶
Returns the namespaces currently registered in the autoloader
isRegistered()¶
returns isRegistered
loadFiles()¶
Checks if a file exists and then adds the file by doing virtual require
register()¶
Register the autoload method
setClasses()¶
Register classes and their locations
setDirectories()¶
Register directories in which "not found" classes could be found
setExtensions()¶
Sets an array of file extensions that the loader must try in each attempt to locate the file
setFileCheckingCallback()¶
Sets the file check callback.
// Default behavior.
$loader->setFileCheckingCallback("is_file");
// Faster than `is_file()`, but implies some issues if
// the file is removed from the filesystem.
$loader->setFileCheckingCallback("stream_resolve_include_path");
// Do not check file existence.
$loader->setFileCheckingCallback(null);
setFiles()¶
Registers files that are "non-classes" hence need a "require". This is very useful for including files that only have functions
setNamespaces()¶
Register namespaces and their related directories
unregister()¶
Unregister the autoload method
requireFile()¶
If the file exists, require it and return true; false otherwise