server/app/Listener/AppBootListener.php

27 lines
650 B
PHP

<?php
namespace App\Listener;
use App\Service\ConfigCacheService;
use App\Service\DictCacheService;
use App\Utils\AppInfoHelper;
use Hyperf\Event\Annotation\Listener;
use Hyperf\Event\Contract\ListenerInterface;
use Hyperf\Framework\Event\BootApplication;
#[Listener]
class AppBootListener implements ListenerInterface
{
public function listen(): array
{
return [BootApplication::class];
}
public function process(object $event): void
{
// 在框架启动时初始化启动时间
AppInfoHelper::initStartTime();
// 初始化配置项缓存
(new ConfigCacheService())->loadAll();
}
}