Declare path listeners for a web app.

Siler comes with 5 convenient helpers for common HTTP methods: GET, POST, PUT, DELETE and OPTIONS.

use Siler\Route;

Route\get('/path', <handler>);
Route\post('/path', <handler>);
Route\put('/path', <handler>);
Route\delete('/path', <handler>);
Route\options('/path', <handler>);

Additional and custom methods can be set using the route function:

Route\route('patch', '/path', <handler>');

As well as multiple methods using an array:

Route\route(['post', 'put'], '/path', <handler>);

Parameters can be set using regular expressions:

Route\get('/number/([0-9]+)', <handler>);

Or the convenient regexifier that will automatically create named groups using brackets {} as delimiters:

Route\get('/number/{n}', <handler>);

Please, note that named groups will match any URL-safe text that is given between slashes. If you need more accurate matching use regular expressions.

The URL matches are available to the handlers by the $params pseudo-global.


Route handlers can be set using:

results matching ""

    No results matching ""