Upgrade to PRO for Only $50/Yearโ€”Limited-Time Offer! ๐Ÿ”ฅ

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 }