Welcome to the homepage
print('i match on GET and POST methods')); // if not satisfied you can use the match function that takes a // string of methods separated by the pipe symbol App::match('get|post|put', '/match', fn() => print('i match on any method you like')); // "any" is a shorthand allowing all HTTP request methods to pass App::any('/example', fn() => print('i match on any method')); //----------------------------------------------------- // Route Parameters //----------------------------------------------------- // capture segments of the URL_PATH within your route. for example, // you may need to capture a users ID. you may do so by defining // route parameters. // parameters are injected into route callbacks based on their order. // a required parameter will only match when a value is supplied App::get('/echo/$text', fn($text) => print($text)); // optional parameter, only the last parameter can be optional // or it will throw an exception App::get('/echo_optional/$text?', fn($text = 'You sent nothing') => print($text)); // crude friends list example App::get('/user/$user_id/friends/$pagination?', function($user_id, $pagination = '0') { ?>Current page: =$pagination?>
print('Hello all routes!
')); //----------------------------------------------------- // Route Groups //----------------------------------------------------- // group together routes and middlewares. a prefix can be added to // prefix each route in the group with a given URL_PATH. the group // will be skipped if the request URL_PATH does not start with the // one supplied. middlewares defined in here will only run on routes // matched from within or any child groups App::group('/test', function() { App::use( fn() => print('Hello all routes matched within this or any child groups!
')); // this will be seen as /test/ App::get('/', fn() => print('Testing 123')); }); // finally, since no route was matched, show a 404 page http_response_code(404); ?>Sorry, the page you requested could not be found