PHP code example of fhooe / router

1. Go to this page and download the library: Download fhooe/router library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fhooe / router example snippets


   $router = new Router();
   

   $logger = new Logger("skeleton-logger");
   // add processors, formatters or handlers to the logger
   $router = new Router($logger);
   

   $router->get("/", function () {
       // e.g., load a view
   });
   

   $router->get("/product/{id}", function ($id) {
      // e.g., load a view to display the product
   });
   

   $router->get("/form[/]", function () {
      // e.g., load a view
   });
   

   $router->set404Callback(function () {
       // e.g., load a 404 view
   });
   

   $router->basePath = "/path/to/your/files";
   

   $router->run();
   

  // v2
  $router->setBasePath("/path");
  // v3
  $router->basePath = "/path";