simplydi/simplyrouter
Composer 安装命令:
composer require simplydi/simplyrouter
包简介
A simple PHP routing system for small apps
README 文档
README
A simple routing system in PHP
Notes
- built for learning purpose
- it is a very simple router. For more powerful features like route naming and middleware implementations, go for League Route or Symfony router
- suitable only for small projects
Usage
include 'src/Router.php'; // or use composer: require 'vendor/autoload.php' $route = new \SimplyDi\SimplyRouter\Router(); $route->match('/', function () { echo "Welcome us"; }); $route->match('/about', function () { echo "About us"; }); $route->match('/policy/privacy', function () { echo "PRIVACY us"; }); $route->match('/post/{slug}', function ($params) { $slug = $params['slug']; echo "Post with slug: " . $slug; }); # using controller classes $route->match('/{slug}', function ($params) { $slug = $params['slug']; return (new PageController)->single($slug); }); $route->run(); // run the router
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-08-04