Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

codersrini's avatar

Route::controller() in Laravel 5.3

We have completed an end-to-end E-Commerce platform using laravel 5.2.x. The project was started in January 2016 and we are in the final stages. Have used Route::controller() method on almost 100+ routes. Changing all these into explicit rules at this stage is really painful task.

At the same time we would like to upgrade laravel to 5.3 and use its benefits such as broadcasting. I just want the controller method back. Is it something that we can extend the router class to 5.2.x's controller method?

Please help. Thanks in advance Srini

0 likes
11 replies
jameswagoner's avatar

From my understanding, Route::controller() was phased out of the docs in version 5.1 implying they scheduled it to be deprecated in a future version, in this case 5.3.

Route::controller() was replaced with Route::resource() which sends the request to the correct controller action based upon the type of http request. It is closest option to replace Route::controller() with. Unfortunately, there will have to be refactoring in your controllers if you decide to migrate to 5.3

1 like
codersrini's avatar

Thanks guys. Let me tryout both the suggestions. Thanks again for the quick responses.

Vinze's avatar

Why on earth did they remove this function? I really like the fact that I can see in the controller which method belongs to which URL. Currently I'm working on a project with hundreds of routes and like 40 controllers and it's a complete chaos when I need to put them all in the routes file(s). All my URL's are build like this:

products -> getIndex()
products/new -> getNew()
products/new -> postNew()
products/edit/{product_id} -> getEdit($product_id)
products/edit/{product_id} -> postEdit($product_id)
products/delete/{product_id} -> postDelete($product_id)

Is it possible to build a package so I will be able to keep working with the Route::controller() method?

Vinze's avatar

@tonym When using resource controller I need to use the exact methods names and routes as defined in the documentation. I also have functions like getImport, postImport, getExport and so on, which means I have to manually create this routes because they are not CRUD.

pmall's avatar

@Vinze just follow the REST convention and your done (shortcut with route:resource())

Vinze's avatar

Unfortunately I can't follow the REST convention because the routes are predefined by some other software which pulls data from my application. It has been removed is because they say it's explicit. I don't share that opinion, and because I can't use the REST convention I'm forced to fill my routes file with hundreds of entries instead of mapping the routes to 40 controllers. Wheres the clarity in that?

Maybe I can hack it back into the framework, but that's not the way I like to solve this problem. Would it be possible to write a service provider or something like that to restore the Route::controller function?

Please or to participate in this conversation.