Project structure

← Project structure

Ashterix

docs(articles): Magento and Symfony examples side by side, request lifecycle as a Mermaid diagram

en/articles/magento-to-symfony/basics/structure.md +6 −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 · module tree

app/
  code/Vendor/Faq/
    registration.php
    etc/module.xml  di.xml  events.xml
    etc/frontend/routes.xml
    etc/adminhtml/system.xml  menu.xml
    etc/acl.xml  webapi.xml  crontab.xml
    etc/db_schema.xml
    Api/  Api/Data/
    Model/  Model/ResourceModel/
    Controller/  Block/  ViewModel/
    view/frontend/layout/  templates/  web/
  etc/env.php  config.php
bin/magento
generated/
pub/index.php  pub/static/
var/  vendor/

Symfony · application tree

bin/console
config/
  bundles.php
  packages/      doctrine.yaml  security.yaml
                 messenger.yaml  monolog.yaml …
  routes.yaml
  services.yaml
migrations/
public/index.php
src/
  Kernel.php
  Controller/  Entity/  Repository/
  Dto/  Message/  MessageHandler/
  EventListener/  Security/
translations/
tests/
var/cache/  var/log/
vendor/
.env  .env.local  .env.test

Magento · module tree

app/
  code/Vendor/Faq/
    registration.php
    etc/module.xml  di.xml  events.xml
    etc/frontend/routes.xml
    etc/adminhtml/system.xml  menu.xml
    etc/acl.xml  webapi.xml  crontab.xml
    etc/db_schema.xml
    Api/  Api/Data/
    Model/  Model/ResourceModel/
    Controller/  Block/  ViewModel/
    view/frontend/layout/  templates/  web/
  etc/env.php  config.php
bin/magento
generated/
pub/index.php  pub/static/
var/  vendor/

Symfony · application tree

bin/console
config/
  bundles.php
  packages/      doctrine.yaml  security.yaml
                 messenger.yaml  monolog.yaml …
  routes.yaml
  services.yaml
migrations/
public/index.php
src/
  Kernel.php
  Controller/  Entity/  Repository/
  Dto/  Message/  MessageHandler/
  EventListener/  Security/
translations/
tests/
var/cache/  var/log/
vendor/
.env  .env.local  .env.test

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.