farmer/iroute

php简单路由

Maintainers

Details

github.com/bejea/iroute

Source

Issues

Installs: 11

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

pkg:composer/farmer/iroute

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

This package is not auto-updated.

Last update: 2025-10-04 01:29:48 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';
});