remysd / simple-router
一个简单的路由器,用于匹配您的URL
1.3.0
2021-04-07 19:21 UTC
This package is auto-updated.
Last update: 2024-10-01 00:14:42 UTC
README
安装
composer require remysd/simple-router
示例
require './vendor/autoload.php'; use RemySd\SimpleRouter\Router; $router = new Router(); $router->setBasePath('/simple-router'); $router->addRoute('/articles', 'article', 'all', 'article_all'); $router->addRoute('/articles/{id}', 'article', 'show', 'article_single'); $properties = $router->match($_SERVER['REQUEST_URI']); $url = $router->generate('single_article', ['id' => 3]);
要求
在 .htaccess
中所需的最小配置
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]