f2 / common
Provides shared functionality and exception classes for F2 libraries.
Requires
- f2/cmd: ^1.0
- league/container: ^3.3
- m1/env: ^2.2
- psr/container: ^1.0
- psr/log: ^1.1
- psr/simple-cache: ^1.0
- symfony/var-exporter: ^5.0
Requires (Dev)
- f2/asserty: ^1.0
README
This library is used by other f2/*-libraries for basic things such as configuration discovery, common exception classes and performance optimizations.
F2::events(): F2\Common\Contracts\EventServiceInterface
Provides the central event dispatcher:
Listening for events
F2::events()->on('some_event_name', function(F2\Common\Contracts\EventInterface $event) {});
Un-listening
F2::events()->off('some_event_name', $handler);
Emitting events
F2::events()->emit(new F2\Common\Event('some_event_name', ['some' => 'data']));
F2::config(string $configName, $defaultValue = null): mixed
Retrieve a configuration value from these sources in order:
$GLOBALS['f2']['config'][$configName]
F2::config()->env($configName)
$GLOBALS['f2']['config']['defaults'][$configName]
Config defaults provided by Manifest classes.
F2::env(string $name): string
Retrieve a configuration value from the environment. Will load a .env file from the project root. If a value is not found, it will load default.env from project root and check for the value there.