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

JoshWilley's avatar

One of Laravel's biggest assets is "making happy developers", right? Most of us are already in the game, so this won't affect us much. But whenever someone new picks up the framework, they are immediately hit with a fork in the road. (Routes).

Do you use annotations or traditional code? Personally, if this was one of the first things I ran into, I would be extremely put off. A framework should be VERY opinionated about the simple things and leave extreme flexibility in the heart of your application.

Something like routing is something that no one really wants to work on or spend time thinking about HOW they should setup routing..

I don't know, it just seems like Taylor may have missed the mark with this one.

8 likes
silence's avatar

@JoshWilley me too, I made a very good framework that handled the routes in YAML files and then compiled like very plain PHP code, it was really fast and I loved it.

Then Symfony2 came out and I was learning it but then I was hired in a project involving Laravel3 and I saw how Laravel handled routes directly with PHP and how convenient that was since I could use require/includes or PHP variable / constants or group routes together with closures and etc. and I felt like there was no need for additional meta programming or pseudo languages.

I think this is the story of many and that's why we moved to Laravel and we dislike route annotations, at the end of the day I hope that, if they are here to stay, route annotations don't become first Laravel citizens but some optional/additional sugar for those who like them.

A final personal note, I teach, use and recommend Laravel every day, it's not that suddenly I don't like Laravel. In fact, I'm looking forward Laravel 5 this is just one little feature that I don't like, that is. I still love method injection and the other new features and hope to use them in production soon.

1 like
kallussed's avatar

I am excited about this change. We use a mix of PHP / Python on the back end, and I really do like how the annotations work in Python. This isn't the same, but it feels close enough to make me happy. Maybe some day soon we can get real annotations as a language feature.

I would like to see the generated routes file preserve the original route order from the controller and append the controller file name in a comment before the generated route code. From the examples given it doesn't look like that's being done. It's good to know where this stuff is coming from.

Options are nice, and I don't think anyone is going to hit a "fork" and stop. They will choose the one they like, and go with it. We can use both Eloquent and the Query Builder without issues, and as long as we have both options the more the merrier.

Opinions and flexibility don't have to be mutually exclusive. We can strive to understand that our "favorite" doesn't work for everybody, and we can provide alternatives. As long as no one forces you to use annotations I see nothing to lose sleep over. I'll use them happily, and I'll still be able to read a routes file if that's used on another project.

JeffreyWay's avatar

Folks - play around with the event scanning annotation, and then tell me that you dislike it. I can't imagine how you possibly could. It's incredibly, incredibly convenient and slick.

Route annotations will come down to preference. If you like it, use it. If you don't, don't.

2 likes
joshmanders's avatar

My biggest gripe with Annotations is just like yesterday's Twitter debate about using Yaml config files over php arrays like it is now. Why add extra overhead just to create the same thing that you were originally doing from the beginning?

Edit://

Also that limits me on what I can and can't do. What if I wanted to use a config variable inside my route? Using Laravel routes like they are now, I can, but with annotations, I don't believe it's possible.

3 likes
drewjo's avatar

I don't think the complaint is actually being able to do it... it's all the technical implications around it. I think @gregibson and @Valorin had some good thoughts around it.

If it comes down to it's just an option to do it that way, and not the only real* way, then awesome! No skin off my back.

*truly supported

1 like
Oddman's avatar

@codeeatbusiness oh, you mean for your actual domain layer, not around your controller routes? I have a few issues with that also, but now I understand where you were coming from. Events should be managed by your code, when something is successful. Imho it's a bad fit for annotations. Annotations should (again, imho) be used for configuration, not code.

alfrednutile's avatar

@JoshWilley I do agree, when I first came to Laravel the ease of routing made it super easy to jump in. If it was annotation focused then I am not sure it would have been so attractive.

With that said I am seeing some of the benefits and beginning to see how to use it and not feel limited.

@JeffreyWay "Route annotations will come down to preference. If you like it, use it. If you don't, don't."

Do you really think that is possible? Like will their be limitations to the non-annotation way? (using middleware for example) And would you suggest not using it even if it would mean not moving forward with the more "Laravel" approach?

headersalreadysent's avatar

I think most of php developers generally wants to became python developer. And lots of them likes annotations only it is like a python.

In our company there are some junior developer. And when i think them, they cant adapt themselfs quickly. And after some time they think laravel is hard.

In my country (Turkey) lots of developer use windows and scares from linux system. Every command from cmd create hate to framework.

lara661's avatar

I think most of php developers generally wants to became python developer. And lots of them likes annotations only it is like a python.

Uh, no ? I like them because they're fast and simple. And again people, facultative. You're all talking like it's the end of the world and stuff, you guys still all aware that can also not use them and just, continue using a routes file ? Or mix and match ?

1 like
suncoastkid's avatar

Annotations don't seem particularly clean or classy IMHO. For me, routes.php is like a blueprint of the app.

Jammyman's avatar

I'm so used to route file that it's hard to let go. I just love that there is one file what tells me everything without running any commands and trying to figure it out in Terminal window. Also those code examples look a bit "muddy" to me.

I will definitely give it a shot when the feature is ready. Right now route:scan doesn't find my app/Http/Controllers/TestController in my test app although it's in the RouteServiceProvider.

JeffreyWay's avatar

@Jammyman - It should definitely work. Are you sure that TestController is included in the $scan array of the route service provider, and that your current environment is set to local?

joshmanders's avatar

You're all talking like it's the end of the world and stuff, you guys still all aware that can also not use them and just, continue using a routes file ? Or mix and match ?

Nobody is talking like it's the end of the world. They're just discussing it and giving their opinions on why they don't like it.

Jammyman's avatar

@JeffreyWay - yes, "php artisan env" says local and TestController is included in the $scan array just the way like HomeController. It's also in same folder and namespace than HomeController. In my understanding that should be enough but I'm probably missing something.

Or maybe I'm not doing it right?

/**
* @Get("test")
*/
public function test()
{
    return 'test';
}
isimmons's avatar

Just trying out annotations on the Larabook app today. Actually they aren't that bad.

Changed my way of looking at it. If I name my controllers well and think in restful terms then it's easy to see mydomain.com/users route can be found at UsersController@index. Of course it gets not so obvious when my 'home' route is in PagesController@splash but then that's what artisan route:list is for.

One minor issue I had is I use single quotes most of the time in PHP so I kept having to backspace and correct to double quotes because the single one causes a syntax error.

Not sure if there can be more complex issues and problems debugging as has been mentioned by some others.

So I could get into annotations for both routes and events. I'll just be needing a cheat sheet with all of the possible annotations :-)

demians's avatar

@isimmons I can't believe what you're saying. Is that true? Do annotations break on single-quote and work on double-quote?

I'm sold. I'm never using this pseudo-annotations for PHP until they make it a language feature (and take 'em out of the comment block.) You guys break your apps when changing comments and changing quoting style. Enjoy.

1 like
JeffreyWay's avatar

That's a Doctrine Annotations specific thing. You must use double quotes. Otherwise, an exception will be thrown.

lprice's avatar

There is a big difference between comments and docblocks, during compile time they are interpreted as different flags and docblocks can be used with reflection and comments not.

Maybe this guy can explain it better

https://www.youtube.com/watch?v=TqyWGbQUPGM

demians's avatar

There is also a big difference between code and ANY of those. One of them is meant to do stuff. The other is metadata.

lprice's avatar

Exactly! You got it!

I read that so many people saying that docblocks are comments, which they are not.

JeffreyWay's avatar

@demians - Lots of projects use annotations. Are all of those maintainers just idiots who don't understand the difference between code and comments? :)

There's no value in all the vitriol that these annotations are getting. Especially when they are an optional thing.

puzbie's avatar

I don't think @demians called anybody idiots. I can understand why people don't like Laravel's new approach to routing though. Most people clearly didn't have a problem with the old way, so don't see why they should have to adapt to the new way. And today's optional feature is tomorrow's obsolete feature.

I can understand why Taylor might want to implement new features to replace old ones, and in the long run, they may indeed be the better way. But I think its a bit naive to expect to be able to implement these changes without people moaning about them. I mean, Christ, we are programmers. Bitching is what we do!

1 like
lprice's avatar

@puzbie just like @demians didn't call anybody idiots, also no-one said that everyone just have to adapt to the new way. :)

Fact is there are a lot of programmers out there who want annotations just like a lot who don't, they probably just don't bother to read this thread. :)

JeffreyWay's avatar

so don't see why they should have to adapt to the new way.

They don't have to adapt. That's what we've been saying over and over.

And today's optional feature is tomorrow's obsolete feature.

No. It is impossible for the routes.php method to become obsolete. People don't seem to understand that.

But I think its a bit naive to expect to be able to implement these changes without people moaning about them.

Why moan about something that doesn't affect you? Taylor didn't remove anything. You can use routes.php. People are so upset about something that literally changes nothing about their workflow.

puzbie's avatar

@lprice, judging by Taylor's poll in the other thread, the majority are happy with the L4 status quo.

@JeffreyWay, it does affect everybody here. Sure as eggs is eggs, your videos (and lets face it, thats why we are here) will be using annotations. I am sure you will soon get fed up of saying "and for those of you still using routes.php".

1 like

Please or to participate in this conversation.