/opt/instcenter/core-1.0.3/dcr/library/App.php
//把use-explain转成useExplain
//把use-explain-vew转成useExplainView
//把use留为use
$actionArr = explode('-', $action);
$actionList = [];
foreach ($actionArr as $key => $actionStr) {
$actionList[$key] = ucfirst($actionStr);
}
$action = implode('', $actionList);
$action = lcfirst($action);
//得出类来
$model = ucfirst($ruleItem->model);
$controller = ucfirst($ruleItem->controller);
//类名
$class = "\\app\\{$model}\\Controller\\{$controller}";
try {
$classObj = new $class;
if (is_callable([$classObj, $action])) {
//获取当前操作方法的参数列表 如果有类就实例化一个
$reflect = new \ReflectionMethod($classObj, $action);
$dependencies = container()->resolveConstructor($reflect->getParameters());
$data = $reflect->invokeArgs($classObj, $dependencies);
} else {
throw new \Exception('Not find the function[' . $action . '] or model[' . $class . ']');
}
} catch (\Exception $e) {
throw $e;
}
return $data;
}
}
/opt/instcenter/core-1.0.3/dcr/library/App.php
@ini_set('display_errors', 'Off');
}
//设置时区
date_default_timezone_set(config('app.default_timezone'));
//如果是命令行就直接返回
$result = '';
if ('cli' == APP::$phpSapiName) {
$result = '';
} else {
//开始处理request
$request = Request::getInstance();
$container->instance('request', $request);
$route = container('route');
//把url解析为ruleItem
$ruleItem = $route->addRuleFromRequest($request);
$result = self::exec($ruleItem);
}
return new Response($result);
}
public static function exec(RuleItem $ruleItem)
{
//去除action里面的-
$action = $ruleItem->action;
//把use-explain转成useExplain
//把use-explain-vew转成useExplainView
//把use留为use
$actionArr = explode('-', $action);
$actionList = [];
foreach ($actionArr as $key => $actionStr) {
$actionList[$key] = ucfirst($actionStr);
}
$action = implode('', $actionList);
$action = lcfirst($action);
/opt/instcenter/core-1.0.3/dcr/bootstrap/init.php
* Time: 21:07
*/
declare(strict_types = 1);
namespace dcr;
define('DS', DIRECTORY_SEPARATOR); //文件分隔符
define('ROOT_FRAME', dirname(__FILE__) . DS . '..'); //dcr目录
define('ROOT_APP', dirname(__FILE__) . DS . '..' . DS . '..' . DS . 'app'); //app目录
define('ROOT_PUBLIC', ROOT_FRAME . DS . '..' . DS . 'public'); //public目录
define('LIB', ROOT_FRAME . DS . 'library');
define('START', microtime(true));
define('CONFIG_EXT', '.php');
define('CONFIG_DIR', ROOT_FRAME . DS . '..' . DS . 'config');
require_once ROOT_FRAME . DS . '..' . DS . 'vendor' . DS . 'autoload.php';
require_once ROOT_FRAME . DS . 'common' . DS . 'function.php';
require_once LIB . DS . 'ClassLoader.php';
require_once LIB . DS . 'App.php';
require_once ROOT_FRAME . DS . '..' . DS . 'common' . DS . 'ChromePhp.php';
return App::init();
/opt/instcenter/core-1.0.3/dcr/bootstrap/app.php
<?php
/**
* Created by [email protected].
* User: dcr
* Date: 2019/7/28
* Time: 21:07
*/
namespace dcr;
$response = require_once __DIR__ . DIRECTORY_SEPARATOR . 'init.php';
$response->send();
/opt/instcenter/core-1.0.3/public/index.php
<?php
/**
* Created by [email protected].
* User: dcr
* Date: 2019/7/27
* Time: 21:39
*/
declare(strict_types=1);
//phpinfo();
namespace dcr;
ini_set('display_errors', 'on');
header('Access-Control-Allow-Origin:*');
require_once __DIR__ . '/../dcr/bootstrap/app.php';