Routes

How to add routes?

Routes must be declare inside index.php

$router Parameters

  • First parameter = route

  • Second parameter = function

$router->get(
  '/home', // home route
  function(){} // function
);

Declare a simple GET method route

Add /about route in index.php as below

/**
 * About Page
 */
$router->get('/about',function(){
    echo "Welcome to about page";
});

Point to views folder

You can require normal php file as below

/**
* Require File
*/
$router->get('/about',function(){
  require __DIR__ . '/views/about.php';
});

Last updated