Reputation: 41
How should I organise the directory/code structure with Symfony4?
I started with
Controller\*BName*\*Fname*\...
Entity\*Fname*\...
Repository\*Fname*\...
Form\*BName*\*Fname*\...
Services\*Fname*\...
Before Symfony4, my structure was
*BName\Controller\*Fname*\...
*BName\Entity\*Fname*\...
...
What is right way?
Upvotes: 1
Views: 227
Reputation: 8162
General structure:
public/
var/
src/
config/
templates/
tests/
In Symfony versions prior to 4.0, it was recommended to organize your own application code using bundles. This is no longer recommended and bundles should only be used to share code and features between multiple applications.
You don't have any Bundle in your source code now.
You can have
--src/
----Controller/
------Admin/
------ProductController.php
----Entity/
----Form/
----Repository/
I would not recommend you to do a service folder as everything is/can be a service. Instead, you should group them according to their responsibilities
----Provider/
------UserProvider.php
----Validator/
----Manager/
----Generator/
------CsvGenerator.php
----Mailer/
Upvotes: 11