daniel-griffiths / simple-route
一个超级简单的路由类
v1.0.0
2017-06-27 19:00 UTC
Requires
- php: ~5.6|~7.0
This package is auto-updated.
Last update: 2024-08-29 04:31:27 UTC
README
一个超级简单的路由器,用于将URL映射到类上的方法。
安装
通过Composer
composer require daniel-griffiths/simple-route
使用方法
<?php require __DIR__.'/vendor/autoload.php'; $router = new DanielGriffiths\Router($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']); // long form for binding a route, supports get/post requests $router->add('GET', '/this-is-a-test', 'ExampleClassName@ExampleMethod'); // short hand for binding a route $router->get('/this-is-a-test', 'ExampleClassName@ExampleMethod'); $router->post('/this-is-a-test', 'ExampleClassName@ExampleMethod'); $router->dispatch();