Skip to content
Devin Smith edited this page Dec 11, 2015 · 1 revision

Advanced Routes

If the first argument of when is an array you can create more customized routes, including multiple comma separated methods.

$tipsy->router()
	->when([
		'route' => 'update',
		'method' => 'post,put',
		'controller' => function() {
			echo 'Updating content...';
		}
	]);

Other ways to do things

Here are a few different ways to define the home page using the methods described above.

$tipsy->router()
	->when('', function() {
		echo 'Here I am';
	});

is the same as

$tipsy->router()
	->when('/', function() {
		echo 'Here I am';
	});

is the same as

$tipsy->router()
	->home(function() {
		echo 'Here I am';
	});

is the same as

$tipsy->router()
	->when([
		'route' => '',
		'method' => '*',
		'controller' => function() {
			echo 'Here I am';
		}
	]);