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

dani3l's avatar

Why is Route::controller() deprecated?

Hi Just updated to latest laravel and It says that the Route::controller() is deprecated

/**
     * Route a controller to a URI with wildcard routing.
     *
     * @param  string  $uri
     * @param  string  $controller
     * @param  array   $names
     * @return void
     *
     * @deprecated since version 5.1.
     */

Couldn't find any info about that in google or laravel docs so.. anybody knows why?

0 likes
18 replies
bobbybouwmann's avatar

It will be deprecated in Laravel 5.2. The call Route::controller was just added as an extra helper, but there are a lot of other ways to fix this in a better way ;)

dani3l's avatar

It's an awesome helper and saves a lot of time If I already can configure routes by (get/post/put/delete/patch)Action why would I register them manually in my routes file? It'll be a very long, ugly and repetitive file.

This method cleans it up and makes it much more easy and understandable to know what the app routes are in a quick look If I want to dig deeper - I just get inside the controller and check it out.

3 likes
JeffreyWay's avatar

I generally don't like Route::controller(). Better to be explicit about your routes.

10 likes
dani3l's avatar

Well, I've heard that a few times in regard to laravel so I'd actually wanna know what are the actual reasons that would benefit with breaking the DRY pattern? Or am I missing DRY completely?

Thanks!

1 like
wing5wong's avatar

Clear definition of routes isnt really breaking DRY at all. With Route::controller() you have no idea what happens with a glance at your routes files

1 like
dani3l's avatar

I think I got it. Thanks for you input guys :)

jekinney's avatar

Why not use resource?

But all this work for a handful of routes? Each route needs to be unique so how does that break dry?

One could actually are using controller() more then once isn't dry either.

larry_x64's avatar

I generally don't like Route::controller(). Better to be explicit about your routes.

What's not explicit about controller methods as route? We have a couple hundreds of routes at work because our administration platform has to deal with a lot of ajax request. Writing all these routes one by one in the routes file is a lot of pain compared to just assigning a URI segment to a controller. IMHO, artisan route:list is more than explicit enough. I always felt like Laravel was saving me a ton of work (and don't get me wrong, it still does, and I still do think that) but I feel like this is a step backwards...

1 like
glandre's avatar

@larry_x64 any clue you got? @wing5wong, I agree with larry... Route::controller() method saves time, just like Auth::routes and also like Route::resource. Are there any problem with Route::controller which doesn't affect these other methods? Will they be deprecated as well?

Vinze's avatar

I agree with you guys! I've been using the Route::controller method all the time and I know a lot of devs that also like to use this method. Sometimes it's just not possible to use the exact REST routes and the Route::resource() method is useless. In large applications with like 40 controller and at least 6 methods per controller you will need to define hundreds of routes.

I always like to keep using the most recent Laravel version and I frequently update my projects to newer versions, but the fact that this is completely removed from 5.3 prevents me from upgrading. Really hope this method will be restored in the future..

2 likes
zamamaz's avatar

I agree, I think Route::controller() is way more useful to be deprecated. I would go back to 5.2 for an up coming project.

vlchris's avatar

Every time I turn around something has been ripped out of the framework that seems like a HUGE portion of the community uses and has gotten used to. We all have multiple projects to maintain, and want to stay up on the latest. I understand there are things that should change but I feel little thought goes into the ramifications of what this will do to the community... Oh lets remove controllers, better to write out each of your routes if they aren't resources..

Yet... the whole reason it seemed for Route::controllers was to simplify and be able to dynamically declare your routes saving you a step. Then it's "Oh we removed routes.php because we're separating out api vs web" .. Really? why couldn't we of left routes.php and added api.php

/rant off... I'm not opposed to change, but, can we at least get used to something for a minute before we have to relearn it, and then patch every project again.

5 likes
jacobrossdev's avatar

It would be better to add new route methods then to completely replace it. I have to agree with everyone complaining about this, and so far I haven't heard any good reason ::controller() was deprecated apart from conjecture.

I also think that explicit routing is anti-pattern in that it allows developers to inject models into the route instead of putting closures into the Controller and calling the method from there. You know, like an MVC?

I feel like the Laravel documentation is also becoming more esoteric so people are forced to purchase the Laracasts IMO. So not only have I wasted time writing this post, I've wasted time trying to relearn Laravel, when I have a deliverable in 3 hours. thanks!

Please or to participate in this conversation.