farmer/iroute

php简单路由

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

This package is not auto-updated.

Last update: 2024-10-04 21:04:43 UTC


README

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

Iroute::dispatch();

Iroute also supports lambda URIs, such as:

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

Iroute::dispatch();

You can also make requests for HTTP methods in Macaw, so you could also do:

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

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

Iroute::dispatch();

Lastly, if there is no route defined for a certain location, you can make Iroute run a custom callback, like:

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