Module クラス

The Module class allows you to easily load, unload, check if a module exists or if it is loaded, or get a list of all modules loaded.

load($module, $path = null)

The load method allows you to load one or more modules at runtime. If the module cannot be found a ModuleNotFoundException will be thrown.

Static Yes
パラメータ
パラメータ 規定値 説明
$module 必須 Name of the module to be loaded, or an array of modules.
$path null Path to the given module. You can use this to load modules from outside the defined module paths.
返り値 void
// load a users module
Module::load('users');

// load the users module from a specific directory
Module::load('users', '/path/to/modules/users/');

// load multiple modules from a single module installation
Module::load( array('Users' => '/path/to/modules/users/', 'Groups' => '/path/to/modules/groups/') );

// load the non-existent module
Module::load('awesome'); // Throws a ModuleNotFoundException

unload($module)

The unload method allows you to unload a module at runtime.

Static Yes
パラメータ
パラメータ 規定値 説明
$module 必須 Name of the module to be unloaded.
返り値 void
// unload the users module
Module::unload('users');

This will remove all loaded routes that point to this module!

loaded($module = null)

The loaded method allows you to check if a module is currently loaded. If no module name is given then all loaded module are returned.

Static Yes
パラメータ
パラメータ 規定値 説明
$module null Name of the module to be checked.
返り値 bool|array
// Check if the users module is loaded
$loaded = Module::loaded('users');

// Get all loaded modules
$loaded = Module::loaded();
/*
Returns something like:
array(
    'users' => '/path/to/users',
    'groups' => '/path/to/groups',
)
*/

exists($module)

The exists method allows you to check if a module exists, i.e. if it can be found in one of the configured module paths. If found, it returns the path to the module. If not, it returns false.

Static Yes
パラメータ
パラメータ 規定値 説明
$module null Name of the module to be checked.
返り値 bool|string
// Optionally load the comments module
if (Module::exists('comments'))
{
	Module::load('comments');
}