I fear that it's sometimes way too easy to forget how difficult simple things can be when you are doing them for the first time. Especially if something doesn't go as planned and you are confronted with an error that you have no idea how to solve.
Is this discussion being moderated?
@alenabdula - What do you mean?
I vote for keeping the file. As @anzze says, sometimes we forget how difficult can be to a newcomer something that we consider easy. I consider that it's better and simple to keep the routes functionality separated. On the other hand, I think that it's a little incorrect to give http routing functionality to all variety of controllers.
@JeffreyWay There was a lengthy post that made some valid points. It disappeared.
Edit it was right after @anzze post above.
@alenabdula Yeah I saw it too... Maybe the author deleted it himself?
@alenabdula - Then he deleted it. Of course I would never sensor this forum. :)
@JeffreyWay even if I say Justin Bieber sucks? :-P
Guys, I think that Jeffrey made a good point before, if Laravel will encourage the use of annotations then the routes.php should be gone, of course I am not a fan of annotations but it makes sense.
Anyway I feel like controllers are not part of your domain but part of your application layer, so it's not the end of the world if it's bound to the framework a little bit. But I still have some concerns about annotations, in which order are they compiled? What happens if I need to use variables, etc.?
My $0.02, adjust for inflation!
I would say remove it, that way people with some Laravel 4 or lower experience but little knowledge of 5 will be forced to ask where it is or read the docs. In this way they'll find out about the updates to 5's routing if they haven't been following it's development and be better informed on it's use.
Should you choose to keep it I think it is in the place it makes the most sense to be!
Without using annotations before, my first opinion is based on the idea and the way they works so I could be wrong but I don't think I'd like to do it that way.
I don't want to have to worry about controllers having the right route placed in them. Would much rather use a single file (or like wise as it is).
☆please include it
Please include it by default.
I'm good with including it, but I do feel your pain regarding it's location; it seems out of place in a namespaced directory.
I'm not sure it's 100% appropriate for /resources, but that's were other supporting, non-namespaced files live; I wouldn't be totally against /resources/routes.
As a frame of reference, the Symfony 3.0 directory structure includes routes within /config (https://github.com/symfony/symfony-standard/issues/584).
+1 for leaving it with the examples in it. Give the user the choice to use annotations or not. My opinion could change, but I like my routes files. There are others that will love annotations.
I've only messed with annotations to see how they work and how to use them, it's slick and easy to use. But, I had issues for example with anything outside of the App folder. Using the
--path='path/to/my/dir
worked great, but it also only takes one path and erased the other routes in there. I worked around it by extending the RouteScanner service and creating my own with a config of directories, but even after that, I still like my routes files.
I digress though...
Personally I don't think should enforce, give the appearance of enforcing or even really strongly encourage annotations. This is one of those spaces vs. tabs discussions where neither side will ever agree and they really shouldn't have to.
+1 for including it default
Regarding newcomers, if they truly are newcomers they will never have met the routes file anyway.
In fact if you're coming from CI or Yii or Cake (perhaps more), you don't "need" to touch route files because they automatically map to controllers/actions. Of course you can change that, Yii's urlmanager for example, but you can create most basic apps without it.
So what I'm saying is don't worry about newcomers, they will learn how to use whichever method is prescribed.
Rather I think it's existing Laravel users who are reluctant to "let go", which is understandable.
Personally I don't mind either way, but whichever is chosen, I want it to be used across the board, otherwise newcomers will certainly become confused when some tutorials use annotations and others use route files.
I have read a few more posts since mine and feel newcomers will become more confused with the routes.php and annotations combination. I find routes.php very useful and any developers that agree can manually create one, which would mean you won't need to worry about where it is located either as it would be down to the developers discretion.
I will be using Route annotations.
My concern is when it comes to someone who is new to the framework, and especially if they haven't used a php framework before, too much 'magic' can confuse/scare them off. With routes.php it's fairly easy to see how it all works, with the route annotations, maybe not so much.
I guess if it's well documented, including how it works in the background, it's not a big issue. But it is something to think about when considering whether we should get rid of routes.php by default.
personally i'd prefer the routes.php file rather than annotations so i can see all my routes centrally, or in a few files is i split them by file. i am not fond of annotations at the moment, consider it confusing if you are not familiar with it.
+1 to keep it and fine where it is.
I'd prefer routes.php file and also an artisan command to create another route file.
I'm not against annotations - but I will be continuning to use my routes.php file. For me, one of the greatest changes between when I switched from Codeigniter to Laravel was having all my routes in one central location.
It is amazing to be able to open a project I have not worked on for 1-2 years and be able to instantly refresh my mind on the application routing (and rough logic) in a few seconds.
I agree with @theshiftexchange comment! Routes file is great, its location is ok to me. I could even imagine it within the config directory... (Why not? It's conf...) About notation, it's a great feature Symfony uses for a while. Letting users chooses there favorite flavour is always great. Removing routes file could be an option but it should be well documented within Laravel Documentation for beginners and best practices.
[UPDATE]
A php artisan command to create routes file could be great too! Being able to create ENV routes file could be great as well. Sometimes one needs routes for different purpose on different ENV without the need to hack..
@JeffreyWay will there be a "--strategy" option for route scanning where you can specify "merge" or "overwrite" ? So if you want to run the route scanning for multiple directories, and merge all the results together.
I'm torn.
@JeffreyWay is right - if routes as we know them are deprecated - or going to be - then there should be no routes file, with (of course) the option of adding it back in on a case by case basis.
But in the space of about two weeks I have gone from being (close to) on top of L4 to being really concerned about how much knowledge I'll be able to bring across to L5. And that bit of me says to leave the routes file in.
@theshiftexchange To be honest I was thinking in the same way, but you need to consider, that even when you only use annotations, you still have routes.scanned.php file and route:list command available to check that overview.
+1 keep it
@garygreen I doubt it.
I would suggest as others have to keep it and in the same location for these reasons.
- quick routes to test an idea our api output experiments. Can't say enough how great this has been.
- quick route to redirect to say angular'a router to handle the ui side of things. This could be in a laravel controller but since in this case it is all Angular doing the work and little Laravel why have the extra Controller. Example below.
- Good place to store docs and or references to docs about people's options eg this file or controller and annotations.
- the location fit the http folder structure
Angular example
$router->get('app', function() {
return View::make('layout.main');
Where layouts/main is an html blade file with the ng-view element rendering the page. No controller needed.
We have multiple ways of doing various things, like the newget () helper function for example. So I don't see an issue with keeping the routes file. But we should get clarification from Taylor, what does it entail to keep or remove the routes file from development of the framework perspective.
Please or to participate in this conversation.