Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Symfony Flex in Action

Symfony Flex in Action

This talk was hold on October 27th with Christian Flothmann (@xabbuh) at SymfonyLive in Berlin.

Symfony Flex is a revolution in the world of Symfony and changes the way of building applications. A developer needs to focus more on dependencies, but can easily increase productivity and lower the footprint of an application. We accompanied Symfony on the way to the new Flex era and will give you concrete examples how application development now looks like and explain the key concepts.

Christopher Hertel

October 27, 2017
Tweet

More Decks by Christopher Hertel

Other Decks in Programming

Transcript

  1. Christopher Hertel Software Developer at SensioLabs Symfony User Group Berlin

    @el_stoffel Christian Flothmann Software Developer at SensioLabs Symfony Docs & Core Team @xabbuh
  2. $ symfony new my-app $ du –sh my-app 53M my-app

    $ cloc my-app 652.336 LOC Standard Edition
  3. . |─ app/ │ |─ config/ | | |─ config.yml

    | | └─ parameters.yml | |─ Resources/ | | └─ views/ | └─ AppKernel.php |─ bin/ | └─ console |─ src/ │ └─ AppBundle/ │ └─ Controller/ |─ var/ |─ vendor/ |─ web/ | |─ app.php | └─ app_dev.php └─ composer.json/lock Symfony Standard Application Config Infrastructure Config Templates Kernel Console Application Source /var DocRoot FrontController Composer
  4. Symfony Standard Flex . |─ bin/ | └─ console |─

    config/ │ |─ packages/ | |─ bundles.php |─ src/ │ |─ Controller/ | └─ Kernel.php |─ templates/ |─ public/ | └─ index.php |─ var/ |─ vendor/ |─ .env └─ composer.json/lock . |─ app/ │ |─ config/ | | |─ config.yml | | └─ parameters.yml | |─ Resources/ | | └─ views/ | └─ AppKernel.php |─ bin/ | └─ console |─ src/ │ └─ AppBundle/ │ └─ Controller/ |─ var/ |─ vendor/ |─ web/ | |─ app.php | └─ app_dev.php └─ composer.json/lock
  5. Symfony Standard Flex . |─ bin/ | └─ console |─

    config/ │ |─ bundles.php | |─ packages/ |─ src/ │ |─ Controller/ | └─ Kernel.php |─ templates/ |─ translations/ |─ public/ | └─ index.php |─ var/ |─ vendor/ |─ .env └─ composer.json/lock . |─ app/ │ |─ config/ | | |─ config.yml | | └─ parameters.yml | |─ Resources/ | | └─ views/ | └─ AppKernel.php |─ bin/ | └─ console |─ src/ │ └─ AppBundle/ │ └─ Controller/ |─ var/ |─ vendor/ |─ web/ | |─ app.php | └─ app_dev.php └─ composer.json/lock |─ translations/ Translations
  6. Symfony Standard Flex . |─ assets/ |─ bin/ | └─

    console |─ config/ │ |─ bundles.php | |─ packages/ |─ src/ │ |─ Controller/ | └─ Kernel.php |─ templates/ |─ public/ │ |─ build/ | └─ index.php |─ var/ |─ vendor/ |─ .env └─ composer.json/lock . |─ app/ │ |─ config/ | | |─ config.yml | | └─ parameters.yml | |─ Resources/ | | └─ views/ | └─ AppKernel.php |─ bin/ | └─ console |─ src/ │ └─ AppBundle/ │ └─ Controller/ |─ var/ |─ vendor/ |─ web/ | |─ app.php | └─ app_dev.php └─ composer.json/lock |─ assets/ │ |─ build/ Webpack Encore
  7. Symfony Standard Flex . |─ config/ │ |─ packages/ |

    | |─ dev/ | | |─ prod/ | | |─ test/ | | |─ doctrine.yaml | | |─ framework.yaml | | └─ security.yaml │ |─ routes/ | | └─ dev/ | | └─ twig.yaml │ |─ bundles.php │ |─ routes.yaml | └─ services.yaml |─ .env |─ .env.dist |─ ... . |-app/ │ |-config/ | | |-config.yml | | |-config_dev.yml | | |-config_prod.yml | | |-config_test.yml | | |-parameters.yml | | |-parameters.yml.dist | | |-routing.yml | | |-routing_dev.yml | | |-security.yml | | └-services.yml |-…
  8. Symfony Standard Flex . |─ config/ │ |─ packages/ |

    | |─ dev/ | | |─ prod/ | | |─ test/ | | |─ doctrine.yaml | | |─ framework.yaml | | └─ security.yaml │ |─ routes/ | | └─ dev/ | | └─ twig.yaml │ |─ bundles.php │ |─ routes.yaml | └─ services.yaml |─ .env |─ .env.dist |─ ... . |-app/ │ |-config/ | | |-config.yml | | |-config_dev.yml | | |-config_prod.yml | | |-config_test.yml | | |-parameters.yml | | |-parameters.yml.dist | | |-routing.yml | | |-routing_dev.yml | | |-security.yml | | └-services.yml |-… Bundle Configuration
  9. Symfony Standard Flex . |─ config/ │ |─ packages/ |

    | |─ dev/ | | |─ prod/ | | |─ test/ | | |─ doctrine.yaml | | |─ framework.yaml | | └─ security.yaml │ |─ routes/ | | └─ dev/ | | └─ twig.yaml │ |─ bundles.php │ |─ routes.yaml | └─ services.yaml |─ .env |─ .env.dist |─ ... . |-app/ │ |-config/ | | |-config.yml | | |-config_dev.yml | | |-config_prod.yml | | |-config_test.yml | | |-parameters.yml | | |-parameters.yml.dist | | |-routing.yml | | |-routing_dev.yml | | |-security.yml | | └-services.yml |-… Environment Specific Configuration
  10. Symfony Standard Flex . |─ config/ │ |─ packages/ |

    | |─ dev/ | | |─ prod/ | | |─ test/ | | |─ doctrine.yaml | | |─ framework.yaml | | └─ security.yaml │ |─ routes/ | | └─ dev/ | | └─ twig.yaml │ |─ bundles.php │ |─ routes.yaml | └─ services.yaml |─ .env |─ .env.dist |─ ... . |-app/ │ |-config/ | | |-config.yml | | |-config_dev.yml | | |-config_prod.yml | | |-config_test.yml | | |-parameters.yml | | |-parameters.yml.dist | | |-routing.yml | | |-routing_dev.yml | | |-security.yml | | └-services.yml |-… Infrastructure Specific Configuration
  11. Symfony Standard Flex . |─ config/ │ |─ packages/ |

    | |─ dev/ | | |─ prod/ | | |─ test/ | | |─ doctrine.yaml | | |─ framework.yaml | | └─ security.yaml │ |─ routes/ | | └─ dev/ | | └─ twig.yaml │ |─ bundles.php │ |─ routes.yaml | └─ services.yaml |─ .env |─ .env.dist |─ ... . |-app/ │ |-config/ | | |-config.yml | | |-config_dev.yml | | |-config_prod.yml | | |-config_test.yml | | |-parameters.yml | | |-parameters.yml.dist | | |-routing.yml | | |-routing_dev.yml | | |-security.yml | | └-services.yml |-… Routing
  12. Symfony Standard Flex . |─ config/ │ |─ packages/ |

    | |─ dev/ | | |─ prod/ | | |─ test/ | | |─ doctrine.yaml | | |─ framework.yaml | | └─ security.yaml │ |─ routes/ | | └─ dev/ | | └─ twig.yaml │ |─ bundles.php │ |─ routes.yaml | └─ services.yaml |─ .env |─ .env.dist |─ ... . |-app/ │ |-config/ | | |-config.yml | | |-config_dev.yml | | |-config_prod.yml | | |-config_test.yml | | |-parameters.yml | | |-parameters.yml.dist | | |-routing.yml | | |-routing_dev.yml | | |-security.yml | | └-services.yml |-… Environment Specific Routing
  13. Symfony Standard Flex . |─ config/ │ |─ packages/ |

    | |─ dev/ | | |─ prod/ | | |─ test/ | | |─ doctrine.yaml | | |─ framework.yaml | | └─ security.yaml │ |─ routes/ | | └─ dev/ | | └─ twig.yaml │ |─ bundles.php │ |─ routes.yaml | └─ services.yaml |─ .env |─ .env.dist |─ ... . |-app/ │ |-config/ | | |-config.yml | | |-config_dev.yml | | |-config_prod.yml | | |-config_test.yml | | |-parameters.yml | | |-parameters.yml.dist | | |-routing.yml | | |-routing_dev.yml | | |-security.yml | | └-services.yml |-… Security Configuration
  14. Symfony Standard Flex . |─ config/ │ |─ packages/ |

    | |─ dev/ | | |─ prod/ | | |─ test/ | | |─ doctrine.yaml | | |─ framework.yaml | | └─ security.yaml │ |─ routes/ | | └─ dev/ | | └─ twig.yaml │ |─ bundles.php │ |─ routes.yaml | └─ services.yaml |─ .env |─ .env.dist |─ ... . |-app/ │ |-config/ | | |-config.yml | | |-config_dev.yml | | |-config_prod.yml | | |-config_test.yml | | |-parameters.yml | | |-parameters.yml.dist | | |-routing.yml | | |-routing_dev.yml | | |-security.yml | | └-services.yml |-… Container Configuration
  15. Symfony Standard Flex . |─ config/ │ |─ packages/ |

    | |─ dev/ | | |─ prod/ | | |─ test/ | | |─ doctrine.yaml | | |─ framework.yaml | | └─ security.yaml │ |─ routes/ | | └─ dev/ | | └─ twig.yaml │ |─ bundles.php │ |─ routes.yaml | └─ services.yaml |─ .env |─ .env.dist |─ ... . |-app/ │ |-config/ | | |-config.yml | | |-config_dev.yml | | |-config_prod.yml | | |-config_test.yml | | |-parameters.yml | | |-parameters.yml.dist | | |-routing.yml | | |-routing_dev.yml | | |-security.yml | | └-services.yml |-… bundles.php
  16. bundles.php <?php return [ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], ];

    <?php return [ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], ]; <?php return [ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], ]; <?php return [ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], Symfony\Bundle\DebugBundle\DebugBundle::class =>['dev'=>true, 'test'=>true], ]; <?php return [ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], Symfony\Bundle\DebugBundle\DebugBundle::class =>['dev'=>true, 'test'=>true], Symfony\Bundle\WebserverBundle\WebserverBundle::class => ['dev' => true], ];
  17. { "bundles": { "Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle": ["all"] }, "copy-from-recipe": { "config/": "%CONFIG_DIR%/",

    "public/": "%PUBLIC_DIR%/", "src/": "%SRC_DIR%/" }, "composer-scripts": { "cache:clear": "symfony-cmd", "assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd" }, "env": { "APP_ENV": "dev", "APP_DEBUG": "1", "APP_SECRET": "%generate(secret)%" }, "gitignore": [ ".env", "/public/bundles/", "/var/", "/vendor/" ] } Example: symfony/framework-bundle
  18. 2. Configuration # config/packages/swiftmailer.yaml swiftmailer: url: '%env(MAILER_URL)%' spool: path: '%kernel.project_dir%/var/mailing-spool'

    # config/routes.yaml controllers: resource: ../src/Controller/ type: annotation defaults: { _format: json }