FrostMVC\Loader
use FrostMVC\Loader;
Autoloading helper for controllers, models, libraries, and helpers.
Wraps the FrostMVC class-loading conventions so that controllers can load dependencies via $this->require->model(), ->library(), or ->helper().
| ->helper() | Includes a helper file from libraries/helpers/. |
| ->library() | Loads a library class from libraries/. When $attachTo is provided, instantiates the class and assigns it as a property on $attachTo. |
| ->load() | Resolves and loads one or more class files from the given path. If $attachTo is set, instantiates each loaded class and assigns it as a property on $attachTo using the unqualified class name. |
| ->model() | Loads a model class from app/models/. When $attachTo is provided, instantiates the class and assigns it as a property on $attachTo. |
$loader->helper($helperName)
Includes a helper file from libraries/helpers/.
| $helperName | string |
The helper filename (without .php extension). |
$loader->library($libraryName, $attachTo = false)
Loads a library class from libraries/. When $attachTo is provided, instantiates the class and assigns it as a property on $attachTo.
| $libraryName | string |
The library class name. |
| $attachTo | object|false |
Object to attach the instantiated library to. Default:false |
$loader->load($path, $classes, $attachTo = false)
Resolves and loads one or more class files from the given path. If $attachTo is set, instantiates each loaded class and assigns it as a property on $attachTo using the unqualified class name.
| $path | string |
Relative directory path (e.g. 'app/models'). |
| $classes | string|array |
A class name or array of class names to load. |
| $attachTo | object|false |
Object to attach instantiated classes to. Default:false |
$loader->model($modelName, $attachTo = false)
Loads a model class from app/models/. When $attachTo is provided, instantiates the class and assigns it as a property on $attachTo.
| $modelName | string |
The model class name. |
| $attachTo | object|false |
Object to attach the instantiated model to. Default:false |
Generated from core/classes/Loader.php (FrostMVC ).