支持更改项目命名空间
This commit is contained in:
parent
0dadd1dba6
commit
be9a922391
|
@ -23,16 +23,21 @@ class Framework {
|
||||||
/**
|
/**
|
||||||
* 执行
|
* 执行
|
||||||
*/
|
*/
|
||||||
public static function startApp() {
|
public static function startApp($callable = '') {
|
||||||
header('content-type: text/html; charset=utf-8');
|
header('content-type: text/html; charset=utf-8');
|
||||||
|
|
||||||
|
if (is_callable($callable)) {
|
||||||
|
$callable(self::class);
|
||||||
|
}
|
||||||
|
|
||||||
// 指定时区
|
// 指定时区
|
||||||
date_default_timezone_set('PRC');
|
date_default_timezone_set('PRC');
|
||||||
|
|
||||||
self::debug();
|
self::debug();
|
||||||
self::frameworkPath();
|
|
||||||
self::appPath();
|
self::appPath();
|
||||||
|
self::appNameSpace();
|
||||||
self::resourcePath();
|
self::resourcePath();
|
||||||
|
self::frameworkPath();
|
||||||
|
|
||||||
require 'library/App.php';
|
require 'library/App.php';
|
||||||
App::start(self::$type, self::$defaultModule);
|
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目录
|
* 指定Resource目录
|
||||||
* @param string $path
|
* @param string $path
|
||||||
|
|
|
@ -16,7 +16,7 @@ class App {
|
||||||
require 'Loader.php';
|
require 'Loader.php';
|
||||||
$loader = new Loader();
|
$loader = new Loader();
|
||||||
$loader->set('top', FRAMEWORK_PATH);
|
$loader->set('top', FRAMEWORK_PATH);
|
||||||
$loader->set('app', APP_PATH);
|
$loader->set(APP_NS, APP_PATH);
|
||||||
$loader->register();
|
$loader->register();
|
||||||
|
|
||||||
// composer自动加载
|
// composer自动加载
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace top\library\route;
|
namespace top\library\route;
|
||||||
|
|
||||||
use top\library\route\ifs\RouteIfs;
|
use top\library\route\ifs\RouteIfs;
|
||||||
|
@ -8,12 +9,18 @@ class Command implements RouteIfs {
|
||||||
// 模块
|
// 模块
|
||||||
public $module = '';
|
public $module = '';
|
||||||
|
|
||||||
|
// 类名
|
||||||
|
public $class = '';
|
||||||
|
|
||||||
// 控制器
|
// 控制器
|
||||||
public $ctrl = '';
|
public $ctrl = '';
|
||||||
|
|
||||||
// 动作
|
// 动作
|
||||||
public $action = '';
|
public $action = '';
|
||||||
|
|
||||||
|
// 参数
|
||||||
|
public $param = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 暂时就这样吧(逃...
|
* 暂时就这样吧(逃...
|
||||||
*/
|
*/
|
||||||
|
@ -21,7 +28,7 @@ class Command implements RouteIfs {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
$this->module = $this->module();
|
$this->module = $this->module();
|
||||||
$this->ctrl = $this->ctrl();
|
$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->action = $this->action();
|
||||||
$this->param = $this->param();
|
$this->param = $this->param();
|
||||||
}
|
}
|
||||||
|
@ -39,7 +46,7 @@ class Command implements RouteIfs {
|
||||||
*/
|
*/
|
||||||
public function ctrl() {
|
public function ctrl() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return 'index';
|
return 'Index';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -169,7 +169,7 @@ class Pathinfo implements RouteIfs {
|
||||||
$this->uriArray = $this->processUriArray();
|
$this->uriArray = $this->processUriArray();
|
||||||
$this->module = $this->module();
|
$this->module = $this->module();
|
||||||
$this->ctrl = $this->ctrl();
|
$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->action = $this->action();
|
||||||
$this->param = $this->param();
|
$this->param = $this->param();
|
||||||
unset($this->uriArray);
|
unset($this->uriArray);
|
||||||
|
|
Loading…
Reference in New Issue