Welcome to FrostSW!

FrostMVC PHP Framework

Documentation   |   Version

Loader

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().

Methods

->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.

helper()

$loader->helper($helperName)

Includes a helper file from libraries/helpers/.

Parameters

$helperName string

The helper filename (without .php extension).

library()

$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.

Parameters

$libraryName string

The library class name.

$attachTo object|false

Object to attach the instantiated library to.

Default: false

load()

$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.

Parameters

$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

model()

$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.

Parameters

$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 ).