f2 / common
1.0.32
2020-12-04 13:35 UTC
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
此库被其他 f2/*-libraries 用于基本功能,如配置发现、通用异常类和性能优化。
F2::events(): F2\Common\Contracts\EventServiceInterface
提供中央事件分发器
监听事件
F2::events()->on('some_event_name', function(F2\Common\Contracts\EventInterface $event) {});
取消监听
F2::events()->off('some_event_name', $handler);
触发事件
F2::events()->emit(new F2\Common\Event('some_event_name', ['some' => 'data']));
F2::config(string $configName, $defaultValue = null): mixed
按顺序从以下来源检索配置值
$GLOBALS['f2']['config'][$configName]
F2::config()->env($configName)
$GLOBALS['f2']['config']['defaults'][$configName]
由 Manifest 类提供的配置默认值。
F2::env(string $name): string
从环境变量中检索配置值。将从项目根目录加载 .env 文件。如果没有找到值,将加载项目根目录的 default.env 并检查该值。