From 6b0df3302e56b7b1886e0c5b997d3046de17ae00 Mon Sep 17 00:00:00 2001 From: ueaner Date: Fri, 30 Mar 2018 17:45:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=B8=B8=E8=A7=81=E7=9A=84?= =?UTF-8?q?=20app,=20db=20=E7=BC=A9=E5=86=99=EF=BC=8C=E4=BD=9C=E4=B8=BA?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=B8=8B=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 16 ++++++++-------- config/config.php | 4 ++-- config/services.php | 8 ++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 5dcb21a..bad9fc5 100644 --- a/README.md +++ b/README.md @@ -134,13 +134,13 @@ server // 基本配置信息 $config = array( // 应用 - 'application' => array( + 'app' => array( 'viewsDir' => BASE_PATH . '/views/', 'logDir' => BASE_PATH . '/var/log/', 'cacheDir' => BASE_PATH . '/var/cache/', ), // 数据库 - 'database' => array( + 'db' => array( 'dsn' => 'mysql:host=localhost;port=3306;dbname=test;charset=utf8', 'username' => 'root', 'password' => 'root', @@ -186,7 +186,7 @@ server // 配置数据库信息, Model中默认获取的数据库连接标志为"db" // 可使用不同的服务名称设置不同的数据库连接信息,供 Model 中做多库的选择 $container->setShared('db', function () { - return new DbConnection($this->config->database); + return new DbConnection($this->config->db); }); // 路由 @@ -212,7 +212,7 @@ server $config = $this->config; $view = new View(); - $view->setViewsDir($config->application->viewsDir); + $view->setViewsDir($config->app->viewsDir); $view->setViewExtension('.twig'); // 通过匿名函数来设置模版引擎,延迟对模版引擎的实例化 @@ -220,7 +220,7 @@ server $engine = new TwigEngine($view); // 开启 debug 不进行缓存 //$engine->setDebug(true); - $engine->setCacheDir($config->application->cacheDir . 'twig'); + $engine->setCacheDir($config->app->cacheDir . 'twig'); return $engine; }); @@ -234,7 +234,7 @@ server $config = $this->config; $view = new View(); - $view->setViewsDir($config->application->viewsDir); + $view->setViewsDir($config->app->viewsDir); $view->setViewExtension('.tpl'); // 通过匿名函数来设置模版引擎,延迟对模版引擎的实例化 @@ -243,8 +243,8 @@ server // 开启 debug 不进行缓存 $engine->setDebug(true); $engine->setOptions(array( - 'compile_dir' => $config->application->cacheDir . 'templates_c', - 'cache_dir' => $config->application->cacheDir . 'templates', + 'compile_dir' => $config->app->cacheDir . 'templates_c', + 'cache_dir' => $config->app->cacheDir . 'templates', 'caching' => true, 'caching_type' => 'file', 'cache_lifetime' => 86400, diff --git a/config/config.php b/config/config.php index e789f8c..6b0012e 100644 --- a/config/config.php +++ b/config/config.php @@ -3,12 +3,12 @@ * 基本配置信息 */ return new \Soli\Config([ - 'application' => [ + 'app' => [ 'viewsDir' => BASE_PATH . '/views/', 'logDir' => BASE_PATH . '/var/log/', 'cacheDir' => BASE_PATH . '/var/cache/', ], - 'database' => [ + 'db' => [ 'dsn' => 'mysql:host=localhost;port=3306;dbname=test;charset=utf8', 'username' => 'root', 'password' => 'root', diff --git a/config/services.php b/config/services.php index 9fa2825..dd4ba34 100644 --- a/config/services.php +++ b/config/services.php @@ -23,12 +23,12 @@ // 配置数据库信息, Model中默认获取的数据库连接标志为"db" // 可使用不同的服务名称设置不同的数据库连接信息,供 Model 中做多库的选择 $container->setShared('db', function () { - return new DbConnection($this->config->database); + return new DbConnection($this->config->db); }); // 日志记录器 $container->setShared('logger', function () { - $logFile = $this->config->application->logDir . '/soli.log'; + $logFile = $this->config->app->logDir . '/soli.log'; $stream = new StreamHandler($logFile, Logger::DEBUG); // 创建应用的主要日志服务实例 @@ -58,7 +58,7 @@ $config = $this->config; $view = new View(); - $view->setViewsDir($config->application->viewsDir); + $view->setViewsDir($config->app->viewsDir); $view->setViewExtension('.twig'); // 通过匿名函数来设置模版引擎,延迟对模版引擎的实例化 @@ -66,7 +66,7 @@ $engine = new TwigEngine($view); // 开启 debug 不进行缓存 $engine->setDebug(true); - $engine->setCacheDir($config->application->cacheDir . 'twig'); + $engine->setCacheDir($config->app->cacheDir . 'twig'); return $engine; });