private function dispatch() { $routes = BASE_PATH . '/app/routes.php'; if (file_exists($routes)) { require $routes; } Route::dispatch(); }
<?php /** * Created by PhpStorm. * User: huxiuchang * Date: 15-9-17 * Time: 下午1:38 */ use NoahBuscher\Macaw\Macaw; Macaw::get('', 'HomeController@home'); Macaw::get('test', function () { echo "成功!"; }); Macaw::$error_callback = function () { throw new Exception("路由无匹配项 404 Not Found"); }; Macaw::dispatch();
public function run($baseNamespace = null) { if ($this->runningInConsole()) { return $this->runCall($baseNamespace); } else { require static::$data_root . '/conf/routes.php'; Route::error(function () use($baseNamespace) { return $this->runCall($baseNamespace); }); Route::dispatch(); //return $this->runCall($baseNamespace); } }
public function run() { Route::dispatch(); }