Routes - adampatterson/Dingo-Framework GitHub Wiki

What Are They?

Routes in Dingo allow you to make a specific page accessible via a unique URL.

Working With Routes

Route configuration for your application can be changed by editing the application/config/development/routes.php file. If you open this up it should look something like this:

// Default Route route::set('default_route','page/home'); Let's say you had a page located at mycontroller/func/argument. Add that onto your domain name and you have a pretty long URL on your hands, so you want to be able to access that exact same page via the very small URL mypage. All you have to do is add the following line to your routes.php file:

route::set('mypage','mycontroller/func/argument'); Now if you visit index.php/mypage you should see the exact same thing as if you visited index.php/mycontroller/func/argument.

Dynamic Routes

Dingo also allows you to use regular expressions in your routes.

route::set('one/([a-zA-Z]+)/([0-9]+)','query/$1/$2');

The above would cause you to see index.php/query/test/123456 if you visited index.php/one/test/123456.

Alternative Style

Dingo also allows you to specify routes like so:

route::set('article/([0-9]+)',array(

	'controller'=>'article',
	'function'=>'view',
	'arguments'=>array('$1')

));

By using alternative style routes you can organize controllers into sub-directories.

route::set('about/([a-zA-Z0-9]+)',array(

	'controller'=>'about/user',
	'function'=>'view',
	'arguments'=>array('$1')

));

This would load the view method from the controller located at application/controllers/about/user.php.