Package クラス

The Package class allows you to easily load, unload, check if a package is loaded, or get all packages loaded.

load($package, $path = null)

The load method allows you to load one or more packages at runtime. If the package cannot be found a PackageNotFoundException will be thrown.

Static Yes
パラメータ
パラメータ 規定値 説明
$package 必須 Name of the package to be loaded, or an array of packages and package paths.
$path PKGPATH Path to the folder in which the package is installed.
返り値 void
// load the orm package
Package::load('orm');

// load the parser package from a specific directory
Package::load('parser', '/path/to/packages/dir/');

// load multiple packages from a single package installation
Package::load( array('First' => PKGPATH.'my'.DS.'first'.DS, 'Last' => PKGPATH.'my'.DS.'last'.DS) );

// load the non-existent package
Package::load('awesome'); // Throws a PackageNotFoundException

unload($package)

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

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

loaded($package = null)

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

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

// Get all loaded packages
$loaded = Package::loaded();
/*
Returns something like:
array(
    'orm' => '/path/to/orm',
    'parser' => '/path/to/parser',
)
*/