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.
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With