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

FLEX - Symfony goes minimal

FLEX - Symfony goes minimal

Symfony 4 brings a new way to develop Symfony applications, which promises lighter and faster apps.

Avatar for Aleš Šarkanj

Aleš Šarkanj

November 28, 2017

More Decks by Aleš Šarkanj

Other Decks in Programming

Transcript

  1. NO NEW FEATURES Major versions are cleanup versions (after 2.0)

    Symfony 4.0 = Symfony 3.4 – deprecated features Gradual upgrade 3.x 3.4 remove deprecations 4.0 → → →
  2. SYMFONY 3.4 OR 4.0 3.4 is a LTS version (supported

    until end of 2021) 4.0 requires PHP 7.1
  3. SYMFONY IS: “Just for big projects” “An overkill for small

    projects” “A monolith framework” “Bloated, has to many features” “Is to complex”
  4. I DON’T LIKE SYMFONY BECAUSE: It’s full stack. It’s too

    complicated. I don’t need all the features, I just need something simple.
  5. DISTRIBUTIONS AS A STARTING POINT A predefined starting point for

    bootstrapping your project (since version 2.0) A basic project with predefined functionalities It gives you everything “ ” whole symfony/symfony, twig, doctrine, security, web profiler, bundles …
  6. REMOVE WHAT YOU DON’T NEED composer remove symfony/swiftmailer-bundle remove it

    from the kernel remove routing remove configuration
  7. A LOT OF MANUAL WORK Basically the same manual procedure

    for every bundle Copy-paste from bundle README
  8. START SMALL GO BIG Start with a minimal set of

    features Only get the essential features in the start Some Core functionalities not installed by default “ ” Grow as you need
  9. MICRO BY DEFAULT New applications created with Symfony 4 are

    based on a micro-kernel and contain 70% less code and files than new Symfony 3 apps
  10. A NEW WAY TO MANAGE SYMFONY APPS Simple and easy

    to create any Symfony app Evolve from a simple to a complex app
  11. HOW DOES FLEX WORK A Composer plugin Hooks into the

    require, install and update commands Integration of libraries and bundles through recipes
  12. AUTOMATE ALL THE THINGS Install an remove bundles with ease

    When installing a bundle, Symfony will now configure it automatically with good defaults.
  13. NO MORE DISTRIBUTIONS Flex is the default way to manage

    and develop Symfony 4 applications
  14. A minimal Symfony project recommended to create new applications A

    single starting point for all types of applications $ composer create-project symfony/skeleton demo ^4.0@RC SYMFONY SKELETON
  15. A SINGLE composer.json FILE { "name": "symfony/skeleton", "minimum-stability": "RC", "require":

    { "php": "^7.1.3", "symfony/console": "^4.0", "symfony/flex": "^1.0", "symfony/framework-bundle": "^4.0", "symfony/lts": "^4@dev", "symfony/yaml": "^4.0" }, "require-dev": { "symfony/dotenv": "^4.0" }, … }
  16. REQUIRE WHAT YOU NEED Everything must be explicitly required forms,

    validation, annotations, security, templating, translations...
  17. PACKAGE NAME ALIASES Short, easy to remember names log, mailer,

    form, orm, validator, admin... High-quality packages
  18. FLEX PACKS Composer meta-package that references a set of related

    packages (composer.json) Examples: orm-pack, debug-pack, profler-pack, api-pack...
  19. orm-pack composer.json { "name": "symfony/orm-pack", "type": "metapackage", "license": "MIT", "description":

    "A pack for the Doctrine ORM", "require": { "php": "^7.0", "doctrine/orm": "^2.5.11", "doctrine/doctrine-bundle": "^1.6.10", "doctrine/doctrine-migrations-bundle": "^1.3" } }
  20. twig-bundle manifest.json { "bundles": { "Symfony\\Bundle\\TwigBundle\\TwigBundle": ["all"] }, "copy-from-recipe": {

    "config/": "%CONFIG_DIR%/", "templates/": "templates/" }, "aliases": ["twig", "template", "templates"] }
  21. SYMFONY RECIPE SERVER Central location for recipes: https://symfony.sh Recipe repositories

    • core (official) https://github.com/symfony/recipes • contrib https://github.com/symfony/recipes-contrib https://symfony.sh
  22. FLEX PROS Better DX – only get what you need

    Automatization Start small, go big Composer plugin
  23. HOW TO MIGRATE TO FLEX No migration tool Upgrade guide

    https://symfony.com/doc/current/setup/flex.html#upgrading-existing-applications-to-flex
  24. CONCLUSION Flex changes the way we build Symfony projects Automation

    of repetitive tasks Opt-in on functionalities “Symfony – The all purpose framework”