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

The router object sends all method calls through the when method using either a 1 or 2 parameter call.

When

Accepts 2 parameters: route and controller. Used for defining a route that matches any method.

$tipsy->router()->when('hello',function() {
	echo 'World';
});
Home

Accepts 1 parameter: controller. Used for specifying the home page. This is equivalent to specifying an empty '' or '/' when method.

$tipsy->router()->home(function() {
	echo 'Honey, Im home!';
});
Get, Post, Put, Delete, or other methods

Accepts 2 parameters: route and controller. Used for defining a route with a specific method. You can use absolutely any method. Even made up ones.

$tipsy->router()->post(function() {
	echo 'Yay! Posting stuff!';
});
$tipsy->router()->bacon(function() {
	echo 'This is a bacon method!';
});
Otherwise

Accepts parameter: controller. If no match is found, the otherwise function will be called. Used for default, or 404 pages.

$tipsy->router()->otherwise(function() {
	echo '404';
});