diff --git a/app/Console/Tasks/MainTask.php b/app/Console/Tasks/MainTask.php index 6523cfe8..8a95568d 100644 --- a/app/Console/Tasks/MainTask.php +++ b/app/Console/Tasks/MainTask.php @@ -2,8 +2,6 @@ namespace App\Console\Tasks; -use App\Models\Chapter; - class MainTask extends Task { @@ -12,13 +10,4 @@ class MainTask extends Task echo "You are now flying with Phalcon CLI!"; } - public function okAction() - { - $chapter = Chapter::findFirstById(15224); - - $chapter->duration = 123; - - echo $chapter->duration; - } - } diff --git a/app/Providers/Cache.php b/app/Providers/Cache.php index 9e1c27cb..03521329 100644 --- a/app/Providers/Cache.php +++ b/app/Providers/Cache.php @@ -24,6 +24,8 @@ class Cache extends AbstractProvider 'host' => $config->redis->host, 'port' => $config->redis->port, 'auth' => $config->redis->auth, + 'index' => $config->redis->index, + 'persistent' => $config->redis->persistent, ]); return $backend; diff --git a/app/Providers/Redis.php b/app/Providers/Redis.php deleted file mode 100644 index ac05c9b5..00000000 --- a/app/Providers/Redis.php +++ /dev/null @@ -1,37 +0,0 @@ -di->setShared($this->serviceName, function () { - - $config = $this->getShared('config'); - - $redis = new \Redis(); - - $host = $config->redis->host ?: '127.0.0.1'; - $port = $config->redis->port ?: 6379; - $persistent = $config->redis->persistent ?: false; - $auth = $config->redis->auth ?: null; - - if ($persistent) { - $redis->pconnect($host, $port); - } else { - $redis->connect($host, $port); - } - - if ($auth) { - $redis->auth($auth); - } - - return $redis; - }); - } - -} \ No newline at end of file diff --git a/app/Providers/Session.php b/app/Providers/Session.php index d07a490b..7405b989 100644 --- a/app/Providers/Session.php +++ b/app/Providers/Session.php @@ -19,8 +19,9 @@ class Session extends AbstractProvider 'host' => $config->redis->host, 'port' => $config->redis->port, 'auth' => $config->redis->auth, + 'index' => $config->session->index, 'lifetime' => $config->session->lifetime, - 'index' => 1, + 'persistent' => $config->redis->persistent, ]); $session->start(); diff --git a/bootstrap/ConsoleKernel.php b/bootstrap/ConsoleKernel.php index 892ae050..a0bf9961 100644 --- a/bootstrap/ConsoleKernel.php +++ b/bootstrap/ConsoleKernel.php @@ -74,7 +74,6 @@ class ConsoleKernel extends Kernel \App\Providers\EventsManager::class, \App\Providers\Logger::class, \App\Providers\MetaData::class, - \App\Providers\Redis::class, \App\Providers\CliDispatcher::class, ]; diff --git a/bootstrap/HttpKernel.php b/bootstrap/HttpKernel.php index 54164a0e..3bf8cc05 100644 --- a/bootstrap/HttpKernel.php +++ b/bootstrap/HttpKernel.php @@ -53,7 +53,6 @@ class HttpKernel extends Kernel \App\Providers\EventsManager::class, \App\Providers\Logger::class, \App\Providers\MetaData::class, - \App\Providers\Redis::class, \App\Providers\Router::class, \App\Providers\Security::class, \App\Providers\Session::class, diff --git a/config/config.default.php b/config/config.default.php index 7daab3cb..78910253 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -7,39 +7,94 @@ $config = []; */ $config['env'] = 'pro'; -$config['key'] = '223B08C66B0EC20466F513C4D9F8115D'; +/** + * 加解密钥 + */ +$config['key'] = 'mlq7jQ1Py8kTdW9m'; +/** + * 所在时区 + */ $config['timezone'] = 'Asia/Shanghai'; -$config['url'] = [ - 'base' => '/', // 必须以"/"结尾 - 'static' => '/static/', // 必须以"/"结尾 -]; +/** + * 网站根地址,必须以"/"结尾 + */ +$config['url']['base'] = '/'; -$config['db'] = [ - 'adapter' => 'Mysql', - 'host' => 'localhost', - 'username' => '', - 'password' => '', - 'dbname' => '', - 'charset' => 'utf8', -]; +/** + * 静态资源地址,必须以"/"结尾 + */ +$config['url']['static'] = '/static/'; -$config['redis'] = [ - 'host' => '127.0.0.1', - 'port' => 6379, - 'persistent' => false, - 'auth' => '', - 'index' => 0, - 'lifetime' => 86400, -]; +/** + * 数据库主机名 + */ +$config['db']['host'] = 'mysql'; -$config['session'] = [ - 'lifetime' => 7200, -]; +/** + * 数据库名称 + */ +$config['db']['dbname'] = 'ctc'; -$config['log'] = [ - 'level' => Phalcon\Logger::INFO, -]; +/** + * 数据库用户名 + */ +$config['db']['username'] = 'ctc'; + +/** + * 数据库密码 + */ +$config['db']['password'] = '1qaz2wsx3edc'; + +/** + * 数据库编码 + */ +$config['db']['charset'] = 'utf8'; + +/** + * redis主机名 + */ +$config['redis']['host'] = 'redis'; + +/** + * redis端口号 + */ +$config['redis']['port'] = 6379; + +/** + * redis链接密码 + */ +$config['redis']['auth'] = '1qaz2wsx3edc'; + +/** + * 数据库编号 + */ +$config['redis']['index'] = 0; + +/** + * redis长链接 + */ +$config['redis']['persistent'] = false; + +/** + * 默认有限期(秒) + */ +$config['redis']['lifetime'] = 86400; + +/** + * 会话有效期(秒) + */ +$config['session']['lifetime'] = 7200; + +/** + * 数据库编号 + */ +$config['session']['index'] = 1; + +/** + * 日志级别 + */ +$config['log']['level'] = Phalcon\Logger::INFO; return $config;