Using automatic controller routes in Laravel is a bad idea

I am coming from CodeIgniter to Laravel.

So, is this a bad idea using automatic routes for all controllers?

Route::controller(Controller::detect());

Should I use this instead of creating routes in routes.php?

+5
source share
5 answers

Yes this is bad.

Controller :: detect () is actually missing in Laravel 4 because it is a bit broken.

detect () will go through your file system and return controller files, but this is a bad idea, because the order you define your routes matters. If you have any nested controllers, you will easily find this violation.

detect() , .

, , .

+9

Laravel, CI, , . , " ". CodeIgniter , + , . Laravel, .

.

+5

- .

Route:: controller ('mycontroller') , Route:: controller (array ('mycontroller', mycontroller2 ');

.

+1

laravel 4:

Restful Controller, http://laravel.com/docs/controllers#restful-controllers

   Route::controller() URL-, -

Route::controller() - ( HTTP-)

:

Route::controller('users','UsersController',array(
            'getUsers' =>"listUsers" , 
           ));

getUsers - listUsers

+1

CRUD .

type php arisan controller:make SampleController

routes.php

Route::resource('sample', 'SampleController'); 

Then enter php artisan routesto show newly created routes

-1
source

All Articles