Skip to content

Application Routes

Stefan Segers edited this page Oct 27, 2021 · 4 revisions

Most of the time a route will have to perform some logic instead of just showing a view.

For simple logic it can be included directly in the route through a function call.

Router::get('/contact', function(){});

The PHP code with the necessary logic is placed between the braces.

For more complex logic usage it is recommended to use a controller class. The route then refers to the method to be executed.

Router::get('/', [controllers\defaultController::class, 'home']);

In this route example the 'home' method of the defaultController in the controllers map will be executed.

Clone this wiki locally