Project structure

← Project structure

Ashterix

docs(articles): Magento and Symfony project trees with hierarchy, checked against the official structure

en/articles/magento-to-symfony/basics/structure.md +96 βˆ’37

4 4
5 5 ::::columns
6 6 :::col
7 βˆ’ **Magento** Β· module tree
7 + **Magento** Β· project tree with a module
8 8
9 9 ```text
10 βˆ’ app/
11 βˆ’ code/Vendor/Faq/
12 βˆ’ registration.php
13 βˆ’ etc/module.xml di.xml events.xml
14 βˆ’ etc/frontend/routes.xml
15 βˆ’ etc/adminhtml/system.xml menu.xml
16 βˆ’ etc/acl.xml webapi.xml crontab.xml
17 βˆ’ etc/db_schema.xml
18 βˆ’ Api/ Api/Data/
19 βˆ’ Model/ Model/ResourceModel/
20 βˆ’ Controller/ Block/ ViewModel/
21 βˆ’ view/frontend/layout/ templates/ web/
22 βˆ’ etc/env.php config.php
23 βˆ’ bin/magento
24 βˆ’ generated/
25 βˆ’ pub/index.php pub/static/
26 βˆ’ var/ vendor/
10 + <magento-root>/
11 + β”œβ”€β”€ app/
12 + β”‚ β”œβ”€β”€ code/
13 + β”‚ β”‚ └── Vendor/
14 + β”‚ β”‚ └── Faq/
15 + β”‚ β”‚ β”œβ”€β”€ registration.php
16 + β”‚ β”‚ β”œβ”€β”€ composer.json
17 + β”‚ β”‚ β”œβ”€β”€ Api/
18 + β”‚ β”‚ β”‚ └── Data/
19 + β”‚ β”‚ β”œβ”€β”€ Block/
20 + β”‚ β”‚ β”œβ”€β”€ Controller/
21 + β”‚ β”‚ β”œβ”€β”€ Model/
22 + β”‚ β”‚ β”‚ └── ResourceModel/
23 + β”‚ β”‚ β”œβ”€β”€ Observer/
24 + β”‚ β”‚ β”œβ”€β”€ Plugin/
25 + β”‚ β”‚ β”œβ”€β”€ Setup/
26 + β”‚ β”‚ β”œβ”€β”€ ViewModel/
27 + β”‚ β”‚ β”œβ”€β”€ etc/
28 + β”‚ β”‚ β”‚ β”œβ”€β”€ module.xml
29 + β”‚ β”‚ β”‚ β”œβ”€β”€ di.xml
30 + β”‚ β”‚ β”‚ β”œβ”€β”€ events.xml
31 + β”‚ β”‚ β”‚ β”œβ”€β”€ acl.xml
32 + β”‚ β”‚ β”‚ β”œβ”€β”€ webapi.xml
33 + β”‚ β”‚ β”‚ β”œβ”€β”€ crontab.xml
34 + β”‚ β”‚ β”‚ β”œβ”€β”€ db_schema.xml
35 + β”‚ β”‚ β”‚ β”œβ”€β”€ frontend/
36 + β”‚ β”‚ β”‚ β”‚ └── routes.xml
37 + β”‚ β”‚ β”‚ └── adminhtml/
38 + β”‚ β”‚ β”‚ β”œβ”€β”€ menu.xml
39 + β”‚ β”‚ β”‚ └── system.xml
40 + β”‚ β”‚ β”œβ”€β”€ i18n/
41 + β”‚ β”‚ └── view/
42 + β”‚ β”‚ └── frontend/
43 + β”‚ β”‚ β”œβ”€β”€ layout/
44 + β”‚ β”‚ β”œβ”€β”€ templates/
45 + β”‚ β”‚ └── web/
46 + β”‚ └── etc/
47 + β”‚ β”œβ”€β”€ config.php
48 + β”‚ └── env.php
49 + β”œβ”€β”€ bin/
50 + β”‚ └── magento
51 + β”œβ”€β”€ generated/
52 + β”œβ”€β”€ pub/
53 + β”‚ β”œβ”€β”€ index.php
54 + β”‚ └── static/
55 + β”œβ”€β”€ var/
56 + └── vendor/
27 57 ```
28 58 :::
29 59 :::col
30 60 **Symfony** Β· application tree
31 61
32 62 ```text
33 βˆ’ bin/console
34 βˆ’ config/
35 βˆ’ bundles.php
36 βˆ’ packages/ doctrine.yaml security.yaml
37 βˆ’ messenger.yaml monolog.yaml …
38 βˆ’ routes.yaml
39 βˆ’ services.yaml
40 βˆ’ migrations/
41 βˆ’ public/index.php
42 βˆ’ src/
43 βˆ’ Kernel.php
44 βˆ’ Controller/ Entity/ Repository/
45 βˆ’ Dto/ Message/ MessageHandler/
46 βˆ’ EventListener/ Security/
47 βˆ’ translations/
48 βˆ’ tests/
49 βˆ’ var/cache/ var/log/
50 βˆ’ vendor/
51 βˆ’ .env .env.local .env.test
63 + <project>/
64 + β”œβ”€β”€ bin/
65 + β”‚ └── console
66 + β”œβ”€β”€ config/
67 + β”‚ β”œβ”€β”€ bundles.php
68 + β”‚ β”œβ”€β”€ preload.php
69 + β”‚ β”œβ”€β”€ routes.yaml
70 + β”‚ β”œβ”€β”€ services.yaml
71 + β”‚ β”œβ”€β”€ packages/
72 + β”‚ β”‚ β”œβ”€β”€ cache.yaml
73 + β”‚ β”‚ β”œβ”€β”€ framework.yaml
74 + β”‚ β”‚ β”œβ”€β”€ doctrine.yaml
75 + β”‚ β”‚ β”œβ”€β”€ messenger.yaml
76 + β”‚ β”‚ β”œβ”€β”€ monolog.yaml
77 + β”‚ β”‚ └── security.yaml
78 + β”‚ └── routes/
79 + β”‚ └── framework.yaml
80 + β”œβ”€β”€ migrations/
81 + β”œβ”€β”€ public/
82 + β”‚ └── index.php
83 + β”œβ”€β”€ src/
84 + β”‚ β”œβ”€β”€ Kernel.php
85 + β”‚ β”œβ”€β”€ Controller/
86 + β”‚ β”œβ”€β”€ Entity/
87 + β”‚ β”œβ”€β”€ Repository/
88 + β”‚ β”œβ”€β”€ EventListener/
89 + β”‚ β”œβ”€β”€ Message/
90 + β”‚ β”œβ”€β”€ MessageHandler/
91 + β”‚ β”œβ”€β”€ Security/
92 + β”‚ └── Dto/
93 + β”œβ”€β”€ templates/
94 + β”œβ”€β”€ translations/
95 + β”œβ”€β”€ tests/
96 + β”œβ”€β”€ var/
97 + β”‚ β”œβ”€β”€ cache/
98 + β”‚ └── log/
99 + β”œβ”€β”€ vendor/
100 + β”œβ”€β”€ .env
101 + β”œβ”€β”€ .env.dev
102 + β”œβ”€β”€ .env.test
103 + β”œβ”€β”€ .env.local
104 + β”œβ”€β”€ composer.json
105 + └── symfony.lock
52 106 ```
53 107 :::
54 108 ::::
109 +
110 + - **Magento:** only `registration.php` and `etc/module.xml` are required, the other module folders appear when you need them. `app/etc/config.php` lists enabled modules, `env.php` holds the DB, cache and environment keys, `generated/` holds the generated Factory, Proxy and Interceptor classes.
111 + - **Symfony:** `symfony/skeleton` creates `bin/`, `config/` (`bundles.php`, `preload.php`, `routes.yaml`, `services.yaml`, `packages/cache.yaml`, `packages/framework.yaml`), `public/index.php`, `src/Kernel.php` and `src/Controller/`, `.env` and `.env.dev` with `APP_SECRET`. Everything else comes from packages (Flex recipes: `doctrine.yaml`, `migrations/`, `src/Entity/`, `templates/`, `.env.test`) and MakerBundle commands (`make:message`, `make:listener`, `make:voter`). `Dto/` is a project convention, and you create `.env.local` yourself; it is not committed.
112 +
113 + Sources: [Symfony project structure](https://symfony.com/doc/current/page_creation.html#checking-out-the-project-structure), [framework-bundle recipe](https://github.com/symfony/recipes/tree/main/symfony/framework-bundle/7.4), [Adobe Commerce module structure](https://developer.adobe.com/commerce/php/development/build/component-file-structure).
55 114
56 115 Laying out `src/` by technical layers (Controller, Entity…) is only a starting template. For a large project you can group by domain (`src/Faq/…`, `src/Catalog/…`), the framework doesn't restrict this: `services.yaml` registers everything in `src/`, and Doctrine looks for entities wherever you point it in `doctrine.yaml`.