S
S
sgidlev2021-10-21 17:41:12
PHP
sgidlev, 2021-10-21 17:41:12

How to structure a Symfony project according to the package-by-feature principle?

Greetings.

I want to try to make the structure of a new application and I want to try the package-by-feature folder organization approach.

Where to store Kernel.php, what to do with migrations and tests. But in general, I want to look at something already implemented.

Can someone give examples of a Symphony project structure based on the package-by-feature principle?

So far I've settled on this structure:

.docker/
bin/
config/
migrations/
public/
src/
    Kernel.php
    API/
        Yandex/
        WebMoney/
    Cart/
        Console/
            UpdateCartCommand.php
        Controller/
            CartController.php
        Entity/
             Cart.php
        Repository/
            CartRepository.php
    Infrastructure/  
    Order/
        Console/
        Controller/
        Entity/
        Repository/
templates/
tests/
translations/
var/
vendor/

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2021-10-21
@sgidlev

Architecture has nothing to do with the framework at all.
From the examples, I can advise an example of Dmitry Eliseev's project on slim . And there is also a report from Valentin Udaltsov about the architecture on Symfony.
1. Store the kernel in srcif it is one.
2. Migrations are possible src/Data/MigrationOr src/Migration
3. Tests, if common (functional), then to /tests, and if unit, then to the folder where the feature is. src/Feature/Test
From your structure, I would put Console and Controllers into one folder at the level with Feature.
Also, I would not do all-in-one services either services.yaml, but I would take them out in config/services/feature.yamlOr in each feature.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question