PHP Classes

File: vendor/altorouter/altorouter/examples/basic/index.php

Recommend this page to a friend!
  Classes of Kabir Hossain   Sage   vendor/altorouter/altorouter/examples/basic/index.php   Download  
File: vendor/altorouter/altorouter/examples/basic/index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Sage
Demo application of Web development framework
Author: By
Last change:
Date: 1 year ago
Size: 1,213 bytes
 

Contents

Class file image Download
<?php

require '../../AltoRouter.php';

$router = new AltoRouter();
$router->setBasePath('/AltoRouter/examples/basic');
$router->map('GET|POST','/', 'home#index', 'home');
$router->map('GET','/users/', array('c' => 'UserController', 'a' => 'ListAction'));
$router->map('GET','/users/[i:id]', 'users#show', 'users_show');
$router->map('POST','/users/[i:id]/[delete|update:action]', 'usersController#doAction', 'users_do');

// match current request
$match = $router->match();
?>
<h1>AltoRouter</h1>

<h3>Current request: </h3>
<pre>
    Target: <?php var_dump($match['target']); ?>
Params: <?php var_dump($match['params']); ?>
Name: <?php var_dump($match['name']); ?>
</pre>

<h3>Try these requests: </h3>
<p><a href="<?php echo $router->generate('home'); ?>">GET <?php echo $router->generate('home'); ?></a></p>
<p><a href="<?php echo $router->generate('users_show', array('id' => 5)); ?>">GET <?php echo $router->generate('users_show', array('id' => 5)); ?></a></p>
<p><form action="<?php echo $router->generate('users_do', array('id' => 10, 'action' => 'update')); ?>" method="post"><button type="submit"><?php echo $router->generate('users_do', array('id' => 10, 'action' => 'update')); ?></button></form></p>