pfinal/routing

The PFinal Routing package.

v1.8.1 2022-03-19 08:56 UTC

This package is auto-updated.

Last update: 2024-10-19 14:41:58 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();