From be9a9223910e9e132443ef8339feb342eccecb61 Mon Sep 17 00:00:00 2001 From: topnuomi <1130395124@qq.com> Date: Thu, 13 Jun 2019 16:46:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=9B=B4=E6=94=B9=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=91=BD=E5=90=8D=E7=A9=BA=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/Framework.php | 18 ++++++++++++++++-- framework/library/App.php | 2 +- framework/library/route/Command.php | 11 +++++++++-- framework/library/route/Pathinfo.php | 2 +- framework/library/template/driver/index.html | 0 5 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 framework/library/template/driver/index.html diff --git a/framework/Framework.php b/framework/Framework.php index 9d13ce3..3df3115 100644 --- a/framework/Framework.php +++ b/framework/Framework.php @@ -23,16 +23,21 @@ class Framework { /** * 执行 */ - public static function startApp() { + public static function startApp($callable = '') { header('content-type: text/html; charset=utf-8'); + if (is_callable($callable)) { + $callable(self::class); + } + // 指定时区 date_default_timezone_set('PRC'); self::debug(); - self::frameworkPath(); self::appPath(); + self::appNameSpace(); self::resourcePath(); + self::frameworkPath(); require 'library/App.php'; App::start(self::$type, self::$defaultModule); @@ -74,6 +79,15 @@ class Framework { } } + public static function appNameSpace($namespace = '') { + if (!defined('APP_NS')) { + if (!$namespace) { + $namespace = 'app'; + } + define('APP_NS', $namespace); + } + } + /** * 指定Resource目录 * @param string $path diff --git a/framework/library/App.php b/framework/library/App.php index 065aa15..1161142 100644 --- a/framework/library/App.php +++ b/framework/library/App.php @@ -16,7 +16,7 @@ class App { require 'Loader.php'; $loader = new Loader(); $loader->set('top', FRAMEWORK_PATH); - $loader->set('app', APP_PATH); + $loader->set(APP_NS, APP_PATH); $loader->register(); // composer自动加载 diff --git a/framework/library/route/Command.php b/framework/library/route/Command.php index 1d8eb82..a8fed7c 100644 --- a/framework/library/route/Command.php +++ b/framework/library/route/Command.php @@ -1,4 +1,5 @@ module = $this->module(); $this->ctrl = $this->ctrl(); - $this->className = APPNS . '\\' . $this->module . '\\controller\\' . $this->ctrl; + $this->class = '\\' . APP_NS . '\\' . $this->module . '\\controller\\' . $this->ctrl; $this->action = $this->action(); $this->param = $this->param(); } @@ -39,7 +46,7 @@ class Command implements RouteIfs { */ public function ctrl() { // TODO Auto-generated method stub - return 'index'; + return 'Index'; } /** diff --git a/framework/library/route/Pathinfo.php b/framework/library/route/Pathinfo.php index 99a630d..2cae277 100644 --- a/framework/library/route/Pathinfo.php +++ b/framework/library/route/Pathinfo.php @@ -169,7 +169,7 @@ class Pathinfo implements RouteIfs { $this->uriArray = $this->processUriArray(); $this->module = $this->module(); $this->ctrl = $this->ctrl(); - $this->class = '\app\\' . $this->module . '\\controller\\' . $this->ctrl; + $this->class = '\\' . APP_NS . '\\' . $this->module . '\\controller\\' . $this->ctrl; $this->action = $this->action(); $this->param = $this->param(); unset($this->uriArray); diff --git a/framework/library/template/driver/index.html b/framework/library/template/driver/index.html new file mode 100644 index 0000000..e69de29