Skip to content

View Routes

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

If your route only needs to return a view, you have to use the Router::get method. Herefore the Router::get method accepts a URI as its first argument and a view name as its second argument. This viewname points to the views map in the application map.

Router::get('/', 'welcome');

This route example means that the root of the applicationURL will point to the 'welcome.php' page in the application/views map.

In addition, you can provide an array of data to pass to the view as an optional third argument.

Router::get('/home','layouts/home',['name'=>'Roscoe Johns']);

This route example means that url/home points to application/views/home.php and that the home.php page has a variable $name and this variable gets the value 'Roscoe Johns'.

Clone this wiki locally