农民/iroute

PHP简单路由

dev-master 2017-08-11 12:27 UTC

This package is not auto-updated.

Last update: 2024-09-20 20:46:47 UTC


README

Iroute::get('/', function() {
  echo 'Hello world!';
});

Iroute::dispatch();

Iroute 也支持 lambda URI,例如

Iroute::get('/(:any)', function($slug) {
  echo 'The slug is: ' . $slug;
});

Iroute::dispatch();

您也可以在 Macaw 中请求 HTTP 方法,因此您也可以这样做

Iroute::get('/', function() {
  echo 'I <3 GET commands!';
});

Iroute::post('/', function() {
  echo 'I <3 POST commands!';
});

Iroute::dispatch();

最后,如果没有为某个位置定义路由,您可以让 Iroute 运行自定义回调,例如

Iroute::error(function() {
  echo '404 :: Not Found';
});