mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-07-17 05:36:13 +08:00
36 lines
992 B
PHP
36 lines
992 B
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Phalcon\Annotations\Adapter\Memory as MemoryAnnotations;
|
|
use Phalcon\Annotations\Adapter\Redis as RedisAnnotations;
|
|
|
|
class Annotation extends Provider
|
|
{
|
|
|
|
protected $serviceName = 'annotations';
|
|
|
|
public function register()
|
|
{
|
|
$this->di->setShared($this->serviceName, function () {
|
|
|
|
$config = $this->getShared('config');
|
|
|
|
if ($config->env == ENV_DEV) {
|
|
$annotations = new MemoryAnnotations();
|
|
} else {
|
|
$annotations = new RedisAnnotations([
|
|
'host' => $config->redis->host,
|
|
'port' => $config->redis->port,
|
|
'auth' => $config->redis->auth,
|
|
'index' => $config->annotation->db,
|
|
'lifetime' => $config->annotation->lifetime,
|
|
'statsKey' => $config->annotation->statsKey,
|
|
]);
|
|
}
|
|
|
|
return $annotations;
|
|
});
|
|
}
|
|
|
|
} |