Closed Kwadz closed 5 years ago
If this is something related to the docs, this issue should be created there instead.
@Kwadz thanks for your proposal. In practice, what you are asking is to go back to the bundle system. In older Symfony versions we had this (what you call "feature folders"):
UserBundle/
Controller/
DefaultController.php
ProductBundle/
Controller/
DefaultController.php
In newer Symfony versions we have this (what you call "tech folders"):
Controller/
UserController.php
ProductController.php
After several years of using and promoting the first option, we decided to go for the second option in Symfony 4. That's why we are not planning to go back to option 1. Also, updating the docs for the other structure would be an huge task that would required thousands of changes. We don't have the resources to do that.
In any case, the good news is that "tech folders" is only the default choice, not the mandatory choice. Sometimes we forget about how infinitely flexible Symfony is. You can use it as a micro-framework or full-stack framework, you can use it with or without bundles, you can apply DDD and hexagonal architecture, you can do traditional CRUD apps or modern Event Source apps, etc.
So, we're closing this as "won't fix" but I hope you understand the reasons and you see that this is not a Symfony limitation, just a default choice that anyone can change to fit their needs. Thanks!
@javiereguiluz, yes I understood the folder structure is now free with Symfony 4, that's why I think the user should be able to choose which structure he needs (for example folder-by-layer that is well suitable for a micro-service architecture, or folder-by-feature that is superior for monolithic architecture).
I wanted to know if Symfony 4 was really ready for folder-by-feature because of some details. For example, is there a proper way to define all the Entity
directories since they are a subfolder of each feature folder:
├── src
│ ├── ...
│ ├── Authentication
│ │ ├── ...
│ │ ├── Entity
│ │ └── ...
│ ├── ShoppingCart
│ │ ├── ...
│ │ ├── Entity
│ │ └── ...
With the bundle-less approach, is there a way to define the doctrine.dbal.orm.mappings
configuration in each directory like Authentication, ShoppingCart (not in app/config.yml to keep things decoupled)?
Yes, you can use the doctrine.orm.mappings
option to tell Doctrine where are your entities defined. See https://symfony.com/doc/current/reference/configuration/doctrine.html#mapping-entities-outside-of-a-bundle
In any case, for specific questions about issues found when using this new dir structure, please refer to any of these channels: https://symfony.com/support Unless you find a Symfony bug related to this. In that case, please open an issue in this repo. Thanks!
The documentation suggests using a folder-by-layer architecture while this is obsolete. In the majority of cases folder-by-feature is superior to folder-by-layer.
We should update the documentation to follow this best practice.
Some readings about it: http://marisks.net/2016/02/16/feature-folders-vs-tech-folders/ http://www.javapractices.com/topic/TopicAction.do?Id=205 https://hackernoon.com/package-by-features-not-layers-2d076df1964d https://dzone.com/articles/package-by-layer-for-spring-projects-is-obsolete