phplegends / routes
一个用于在 PHP 中处理路由的包
0.1.1
2020-05-27 02:00 UTC
Requires
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is auto-updated.
Last update: 2024-09-16 14:50:51 UTC
README
#PHPLegends Routes
PHPLegends\Routes 是一个用于简化应用程序路由的包。
对于“Hello World”,你可以尝试这样做
include __DIR__ . '/vendor/autoload.php'; $router = new \PHPLegends\Routes\Router; $router->get('/', function () { return 'Hello World'; }); $page = isset($_GET['page']) ? $_GET['page'] : '/'; $dispatcher = new \PHPLegends\Routes\Dispatcher($page, $_SERVER['REQUEST_METHOD']); echo $router->dispatch($dispatcher);
现在,在你的 index.php
文件夹中运行 php -s localhost:8000