john-jun/route

简单的RESTful风格请求路由

1.0.0 2020-06-01 11:28 UTC

This package is auto-updated.

Last update: 2024-09-29 05:29:49 UTC


README

简单的RESTful风格请求路由

安装

使用composer安装

composer require john-jun/route

测试

composer test

使用方法

$route = new Air\Routing\Route();

//add route
$route->get('/get', '{className}@{method}');
$route->cli('/cli', '{className}@{method}');
$route->put('/put', '{className}@{method}');
$route->head('/head', '{className}@{method}');
$route->post('/post', '{className}@{method}');
$route->patch('/patch', '{className}@{method}');
$route->delete('/delete', '{className}@{method}');
$route->options('/options', '{className}@{method}');

//add route group
$route->group('prefix', static function(Air\Routing\Route $route) {
    $route->get('/get', '{className}@{method}');
    $route->cli('/cli', '{className}@{method}');
    $route->put('/put', '{className}@{method}');
    $route->head('/head', '{className}@{method}');
    $route->post('/post', '{className}@{method}');
    $route->patch('/patch', '{className}@{method}');
    $route->delete('/delete', '{className}@{method}');
    $route->options('/options', '{className}@{method}');
});

print_r($route->dispatch('/get'));
print_r($route->dispatch('/prefix/get'));