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