Controller.php
public static function create($route)
    {
        if (($route = trim($route, '/')) === '') {
            $route = App::app()->config['defaultController'];
        }

        $route .= '/';
        if (($pos = strpos($route, '/')) !== false) {
            // 得到controller id
            $id = substr($route, 0, $pos);
            //controller id必须是字母
            if (!preg_match('/^\w+$/', $id)) {
                return null;
            }

            $className = ucfirst($id) . 'Controller';
            $fullClassName = App::app()->namespace . '\core\controller\\' . $className;
            $classFile = App::app()->getControllerPath() . '\\' . $className . '.php';

            if (is_file($classFile)) {
                if (!class_exists($fullClassName, false)) {
                    require $classFile;
                }

                if (class_exists($fullClassName, true) && is_subclass_of($fullClassName, 'Li\Controller')) {
                    $id[0] = strtolower($id[0]);

                    $route = substr($route, $pos + 1);

                    $seg = strpos($route, '/');

                    if (($actionId = substr($route, 0, $seg)) == false) {
                        $actionId = '';
                    }
                    // 初始化$_GET
                    \Li\Route::instance()->parseActionParams(substr($route, $seg + 1));

                    $controller = new $fullClassName($id);
                    $controller->init();
                    $controller->runAction((empty($actionId) ? App::app()->config['defaultAction'] : $actionId));

                    return $controller;
                } else {
                    echo 'controller must extends Controller!';
                    die;
                }

                return null;
            } else {
                Log::log()->warning("controller $fullClassName not exist");
                if(!App::app()->config['debug']){
                    redirect('/404.html');
                }
            }
        } else {
            echo 'error';
        }
    }
public static function create($route)
    {
        if (($route = trim($route, '/')) === '') {
            $route = App::app()->config['defaultController'];
        }

        $route .= '/';
        if (($pos = strpos($route, '/')) !== false) {
            // 得到controller id
            $id = substr($route, 0, $pos);
            //controller id必须是字母
            if (!preg_match('/^\w+$/', $id)) {
                return null;
            }

            $className = ucfirst($id) . 'Controller';
            $fullClassName = App::app()->namespace . '\core\controller\\' . $className;
            $classFile = App::app()->getControllerPath() . '\\' . $className . '.php';

            if (is_file($classFile)) {
                if (!class_exists($fullClassName, false)) {
                    require $classFile;
                }

                if (class_exists($fullClassName, true) && is_subclass_of($fullClassName, 'Li\Controller')) {
                    $id[0] = strtolower($id[0]);

                    $route = substr($route, $pos + 1);

                    $seg = strpos($route, '/');

                    if (($actionId = substr($route, 0, $seg)) == false) {
                        $actionId = '';
                    }
                    // 初始化$_GET
                    \Li\Route::instance()->parseActionParams(substr($route, $seg + 1));

                    $controller = new $fullClassName($id);
                    $controller->init();
                    $controller->runAction((empty($actionId) ? App::app()->config['defaultAction'] : $actionId));

                    return $controller;
                } else {
                    echo 'controller must extends Controller!';
                    die;
                }

                return null;
            } else {
                Log::log()->warning("controller $fullClassName not exist");
                if(!App::app()->config['debug']){
                    redirect('/404.html');
                }
            }
        } else {
            echo 'error';
        }
    }
创建一个控制器
@param  [type] $route [description]
@return [type]        [description]