pfinal/routing

The PFinal Routing package.

v1.8.0 2019-05-30 02:26 UTC

This package is auto-updated.

Last update: 2020-10-30 01:57:10 UTC


README

安装

环境要求:PHP >= 5.4、7+

composer require pfinal/routing

使用示例

require __DIR__ . '/vendor/autoload.php';

use Symfony\Component\HttpFoundation\Request;
use PFinal\Routing\Router;

$router = new Router();

$router->get('/', function () {
    return 'index';
});

$router->any('/blog/:id', function ($id) {
    return $id;
});

$router->post('/blog/:name/update', function ($name) {
    return $name;
});

$request = Request::createFromGlobals();

$response = $router->dispatch($request);
$response->send();