Project structure

← Project structure

Ashterix

feat(seo): og:image size for front matter images; short titles and explicit descriptions for From Magento to Symfony

en/articles/magento-to-symfony/basics/structure.md +2 βˆ’1

Project structure

A new project: symfony new faq --webapp (Symfony CLI) or composer create-project symfony/skeleton faq for a minimal set. Flex adds packages together with their config: composer require orm creates config/packages/doctrine.yaml and the DATABASE_URL variable.

Magento Β· project tree with a module

<magento-root>/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ code/
β”‚   β”‚   └── Vendor/
β”‚   β”‚       └── Faq/
β”‚   β”‚           β”œβ”€β”€ registration.php
β”‚   β”‚           β”œβ”€β”€ composer.json
β”‚   β”‚           β”œβ”€β”€ Api/
β”‚   β”‚           β”‚   └── Data/
β”‚   β”‚           β”œβ”€β”€ Block/
β”‚   β”‚           β”œβ”€β”€ Controller/
β”‚   β”‚           β”œβ”€β”€ Model/
β”‚   β”‚           β”‚   └── ResourceModel/
β”‚   β”‚           β”œβ”€β”€ Observer/
β”‚   β”‚           β”œβ”€β”€ Plugin/
β”‚   β”‚           β”œβ”€β”€ Setup/
β”‚   β”‚           β”œβ”€β”€ ViewModel/
β”‚   β”‚           β”œβ”€β”€ etc/
β”‚   β”‚           β”‚   β”œβ”€β”€ module.xml
β”‚   β”‚           β”‚   β”œβ”€β”€ di.xml
β”‚   β”‚           β”‚   β”œβ”€β”€ events.xml
β”‚   β”‚           β”‚   β”œβ”€β”€ acl.xml
β”‚   β”‚           β”‚   β”œβ”€β”€ webapi.xml
β”‚   β”‚           β”‚   β”œβ”€β”€ crontab.xml
β”‚   β”‚           β”‚   β”œβ”€β”€ db_schema.xml
β”‚   β”‚           β”‚   β”œβ”€β”€ frontend/
β”‚   β”‚           β”‚   β”‚   └── routes.xml
β”‚   β”‚           β”‚   └── adminhtml/
β”‚   β”‚           β”‚       β”œβ”€β”€ menu.xml
β”‚   β”‚           β”‚       └── system.xml
β”‚   β”‚           β”œβ”€β”€ i18n/
β”‚   β”‚           └── view/
β”‚   β”‚               └── frontend/
β”‚   β”‚                   β”œβ”€β”€ layout/
β”‚   β”‚                   β”œβ”€β”€ templates/
β”‚   β”‚                   └── web/
β”‚   └── etc/
β”‚       β”œβ”€β”€ config.php
β”‚       └── env.php
β”œβ”€β”€ bin/
β”‚   └── magento
β”œβ”€β”€ generated/
β”œβ”€β”€ pub/
β”‚   β”œβ”€β”€ index.php
β”‚   └── static/
β”œβ”€β”€ var/
└── vendor/

Symfony Β· application tree

<project>/
β”œβ”€β”€ bin/
β”‚   └── console
β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ bundles.php
β”‚   β”œβ”€β”€ preload.php
β”‚   β”œβ”€β”€ routes.yaml
β”‚   β”œβ”€β”€ services.yaml
β”‚   β”œβ”€β”€ packages/
β”‚   β”‚   β”œβ”€β”€ cache.yaml
β”‚   β”‚   β”œβ”€β”€ framework.yaml
β”‚   β”‚   β”œβ”€β”€ doctrine.yaml
β”‚   β”‚   β”œβ”€β”€ messenger.yaml
β”‚   β”‚   β”œβ”€β”€ monolog.yaml
β”‚   β”‚   └── security.yaml
β”‚   └── routes/
β”‚       └── framework.yaml
β”œβ”€β”€ migrations/
β”œβ”€β”€ public/
β”‚   └── index.php
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ Kernel.php
β”‚   β”œβ”€β”€ Controller/
β”‚   β”œβ”€β”€ Entity/
β”‚   β”œβ”€β”€ Repository/
β”‚   β”œβ”€β”€ EventListener/
β”‚   β”œβ”€β”€ Message/
β”‚   β”œβ”€β”€ MessageHandler/
β”‚   β”œβ”€β”€ Security/
β”‚   └── Dto/
β”œβ”€β”€ templates/
β”œβ”€β”€ translations/
β”œβ”€β”€ tests/
β”œβ”€β”€ var/
β”‚   β”œβ”€β”€ cache/
β”‚   └── log/
β”œβ”€β”€ vendor/
β”œβ”€β”€ .env
β”œβ”€β”€ .env.dev
β”œβ”€β”€ .env.test
β”œβ”€β”€ .env.local
β”œβ”€β”€ composer.json
└── symfony.lock

What is in the Magento tree

Path What it is
registration.php, etc/module.xml Required module files. The other folders appear when you need them.
app/etc/config.php The list of enabled modules.
app/etc/env.php DB, cache and environment keys.
generated/ Generated Factory, Proxy and Interceptor classes.

Where the Symfony tree comes from

Path Created by
bin/, config/, public/index.php, src/Kernel.php, src/Controller/ symfony/skeleton
.env, .env.dev with APP_SECRET the framework-bundle recipe
config/packages/doctrine.yaml, migrations/, src/Entity/, src/Repository/ composer require orm
templates/ composer require twig
tests/, .env.test composer require --dev symfony/test-pack
src/Message/, src/MessageHandler/ make:message
src/EventListener/ make:listener
src/Security/Voter/ make:voter
src/Dto/ a project convention
.env.local you create it yourself; it is not committed

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.