pfinal / routing
The PFinal Routing package.
v1.8.1
2022-03-19 08:56 UTC
Requires
- php: ^5.4 || ^7.0
- pfinal/container: ~1.1
- pfinal/pipeline: ~1.1
- psr/http-message: ^1.0
- symfony/http-foundation: ~2.3 || ~3.0
- symfony/psr-http-message-bridge: ^1.0
- zendframework/zend-diactoros: ^1.0
Requires (Dev)
- symfony/var-dumper: ^4.2
README
安装
环境要求:PHP >= 5.4、7+
- 使用 composer
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();