define("APP_PATH", realpath(dirname(__FILE__) . '/../'));
$app = new Yaf_Application(APP_PATH . "/conf/application.ini");
$app->bootstrap()->getDispatcher()->dispatch(new Yaf_Request_Simple());
public function _initRoute(Yaf_Dispatcher $dispatcher)
{
$router = $dispatcher->getRouter();
if (isset($_SERVER['REQUEST_URI'])) {
$uri = explode('-', $_SERVER['REQUEST_URI']);
$module = trim($uri['0'], '/');
$arrroutes = array(
$module => new Yaf_Route_Regex('#' . $module . '-([\w-]+).html#', array(
'module' => 'index',
'controller' => $module,
'action' => 'index'
), array(
1 => 'id'
))
);
foreach ($arrroutes as $key => $routes) {
$router->addRoute($key, $routes);
}
}
}
//在cli模式下request_uri跟的是你的请求路径,就能像普通的yaf url请求一样请求到/swoole/index,
php swoole.php 'request_uri=/swoole/index'