Skip to content
Devin Smith edited this page Dec 10, 2015 · 6 revisions

Aliases allow you to map one or multiple existing routes to new routes. Params are also mapped. Each From Param is mapped to the To Param you provide.

$tipsy->router()
	->when('item/edit/:id', function($Params) {
		echo $Params->id;
	})
	->alias('item/:id/edit', 'item/edit/:id');
$tipsy->run();

When requesting item/1/edit it will echo 1.


Aliases also take over the methods of the parent, so you can have multiple separate methods using the same alias.

$tipsy->router()
	->post('item/edit/:id', function($Params) {
		// save the item
	})
	->get('item/edit/:id', function($Params) {
		// retrieve the item
	})
	->alias('item/:id/edit', 'item/edit/:id');
$tipsy->run();