Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

laravel routing like code igniter

Im trying to switch from using code igniter to laravel however I noticed in every tutorial I'd followed, we always declare the route in route.php in laravel unlike in code igniter that it has a default routing like http://localhost/projname/controller/method. Is there a way to have an auto routing like CI or I'd just missed something in laravel routing rules?This is very important because we all know big websites have more than 50 links and it will be a hustle if we are going to declare those all in routes.php in laravel.

like image 277
Orvyl Avatar asked May 29 '13 00:05

Orvyl


1 Answers

Is there a way to have an auto routing like CI

Why yes there is. In your route file do Route::controller(Controller::detect());

Now in your controller class make sure each function name is concatenated with action_. So if your function name is homepage() then make it action_homepage()

Keep in mind that you can use restful controller names get_homepage() and post_homepage(). But you'll have to declare this class variable in your controller public static $restful = true;

like image 130
Seph Avatar answered Oct 08 '22 19:10

Seph