File src/class/Lia.php

class Lia

Constants

Properties

  • public string $cache_dir = __DIR__.'/../../cache/';
  • public array $apps; array <string namespace, \Lia\App $app>
  • public array $events; array<\Lia\Events $event_name, array $callable_list>
    callable_list is an array of callables.
    Each event defines its own callback signature & is typically defined via an interface
    Example: Lia\ResponseInterface has signatures for events emitted by Liaison during deliver()
    Handling an event does not require the interface be implemented.

For complex systems, I recommend using an interface.

  • public array $methods; array<string $method_name, callable $callable>
  • public bool $is_ready = false; Whether ready() has been called or not.
    deliver() only calls ready() when $is_ready is false.

Methods

  • public function addMethod(string $method_name, callablestring $callable) Add a global method to Liaison. Overwrites if it already exists.

  • public function addApp(\Lia\AppInterface $app)

  • public function addon(string $addon_fqn): \Lia\AddonInterface Load an addon via it's fully qualified name.

  • public function emit(string $event_name, ...$args): array Emit an event

  • public function hook(string $event_name, callablearray $callable)

  • public function ready() ready up all apps

  • public function finish() Call onFinish() on all apps, then emit Events::Finish event.
    Does NOT stop execution. Use terminate() to stop execution or exit on your own

  • public function terminate() Call onTerminate() on all apps, then emit Events::terminate
    exits.

  • public function deliver(\Lia\Http\Request $request = new \Lia\Http\Request(), \Lia\Http\Response $response null)

  • public function execute(\Lia\CliExecution $cli)

  • public function throw(\Exception $e, string $user_message = "") Throw an exception & report error to user.