PHP code example of mombol / router

1. Go to this page and download the library: Download mombol/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/ */

    

mombol / router example snippets


use \Mombol\Router\Router;

Router::get('/', function() {
  return 'Hello world!';
});

Router::get('/(:any)', function($slug) {
  return 'The slug is: ' . $slug;
});

Router::get('/', function() {
  return 'I <3 GET commands!';
});

Router::post('/', function() {
  return  'I <3 POST commands!';
});

Router::error(function() {
  return '404 :: Not Found';
});

Router::dispatch(function($content){
  if (!empty($content) && is_string($content)) {
    echo $content;
  }
});