File src/class/Package.php
class Lia\Package
See source code at /src/class/Package.php
Constants
Properties
-
public string $name;
example: package -
public string $fqn;
example: vendor:package -
public string $dir = null;
The root dir for the package -
public \Lia $lia;
Liaison object -
public array $addons = [];
array of addons -
protected array $config = [];
Configurations for the package
Methods
-
public function __construct(\Lia $liaison, string $fqn, string $dir=null)
-
public function ready()
Callsaddon->onParentReady()
for each addon in this package. This is called automatically during package constructor, but can also be triggered manually if addons are added manually after instantiation. -
public function onConfigured(array $configs)
Called after configurations are loaded fromPACKAGE_DIR/config.json
, before bootstrapping. -
public function onBootstrapped()
Called after bootstrap file isrequire
d (PACKAGE_DIR/bootstrap.php). This is called even if there is no bootstrap file. -
public function onAddonsLoaded(array $addons)
Called after addons have been instantiated. Addons may not be fully setup yet, as addon->onParentReady() has not been called yet. -
public function onPackageAdded(\Lia\Package $package)
Called when any other package is added, after it is fully setup (config, bootstrap, and addons have been loaded).
This is also called for previously-added packages. When Package 2 is added, Package1->onPackageAdded(Package2) will be called AND Package2->onPackageAdded(Package1) will be called.
Never called for itself. When Package 2 is added, Package2->onPackageAdded(Package2) will never be called.
-
protected function bootstrap()
require()
the bootstrap.php file in the package's root dir, if it exists.
It's called after the Package class has been initialized, with name, dir, lia, and fqn set. Addons are not yet loaded.
If you use addons, call '$this->load_addons()' in your bootstrap.php file
-
public function load_addons($sub_dir = 'addon')
instantiate all addons in the given addon subdirectory. -
public function dir(string $sub_dir): string
Return the absolute path to a directory inside your package -
public function config(string $key): mixed
Get a config's value ornull
if it is not set -
public function setConfig(string $key, intstringboolfloatarray $value): void
Set the config's value to a primitive value or array. Arrays should NOT contain objects, only that which can be expressed in JSON.