PHP Classes

File: test/php/test4.php

Recommend this page to a friend!
  Classes of Nikos M.   Dromeo PHP Router Library   test/php/test4.php   Download  
File: test/php/test4.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Dromeo PHP Router Library
Route HTTP requests to functions with URL patterns
Author: By
Last change:
Date: 1 year ago
Size: 990 bytes
 

Contents

Class file image Download
<?php

require(dirname(__FILE__) . '/../../src/php/Dromeo.php');

function
defaultHandler($route)
{
    echo(
'Default Handler' . PHP_EOL);
   
print_r($route);
}

$router = new Dromeo();

$router->onGroup('/foo', function($router) {
   
$router
       
->on([
           
'route'=> '/koo',
           
'method'=> '*',
           
'handler'=> 'defaultHandler'
       
])
        ->
onGroup('/moo', function($router) {
           
$router
               
->on([
                   
'route'=> '',
                   
'method'=> '*',
                   
'handler'=> 'defaultHandler'
               
])
                ->
on([
                   
'route'=> '/soo',
                   
'method'=> '*',
                   
'handler'=> 'defaultHandler'
               
])
            ;
        })
    ;
});

echo(
'Dromeo.VERSION = ' . Dromeo::VERSION . PHP_EOL);
echo(
PHP_EOL);

$router->route('/foo/koo', '*', true);
$router->route('/foo/moo', '*', true);
$router->route('/foo/moo/soo', '*', true);