在框架外套一个路由器,单独处理部分请求

...前略

$_run_ci_ = false;

$_methods_ = 'GET|POST|PUT|DELETE|OPTIONS|PATCH|HEAD';

if (isset($_SERVER['REQUEST_METHOD']) &&
     in_array(strtoupper($_SERVER['REQUEST_METHOD']), explode('|', $_methods_))) {
    // Create Router instance
    $router = new \Bramus\Router\Router();
    
    # loader
    include APPPATH . 'hooks/doufu_autoload.php';
    $_doufu_loader_ = new doufu_autoload();
    $_doufu_loader_->run();
    
    // Define routes
    require_once dirname(__FILE__) . "/../../app/config/router.php";
    # default router
    $router->match($_methods_, '.*', function () use (&$_run_ci_) {
        $_run_ci_ = true;
    });
    
    // Run it!
    $router->run();
} else {
    $_run_ci_ = true;
}

if ($_run_ci_) {
    require_once BASEPATH . 'core/CodeIgniter.php';
}

路由器项目地址:https://github.com/bramus/router