Slide 1

Slide 1 text

Fabien Potencier @fabpot

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

What is Symfony 4? = Symfony 3.4 LTS - deprecated features - long term support - PHP 5 support + new dev workflow via Flex

Slide 4

Slide 4 text

Flex Composition over Inheritance

Slide 5

Slide 5 text

Flex in 1 sentence Flex helps developers manage the life-cycle of project dependencies by automating boring tasks, For projects of any size, from micro to monolith, For any kind of applications, API or Web.

Slide 6

Slide 6 text

Flex in 10 seconds Projects do not depend on symfony/symfony No third-party dependencies/bundles Add dependencies when you need them Nothing to remove, the bare minimum

Slide 7

Slide 7 text

Flex behind the scenes Composer plugin Uses “recipes” to install/uninstall any Composer package (enables bundles, auto-configures packages, …)

Slide 8

Slide 8 text

Flex in action…

Slide 9

Slide 9 text

$ composer create-project symfony/skeleton demo # Before Symfony 4 stable $ composer create-project -s beta symfony/ skeleton demo

Slide 10

Slide 10 text

symfony/skeleton "require": { "php": "^7.0.8", "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" },

Slide 11

Slide 11 text

symfony/lts Enforces Long Term Supported versions of the Symfony Components

Slide 12

Slide 12 text

$ composer create-project symfony/skeleton demo Demo

Slide 13

Slide 13 text

$ composer create-project symfony/skeleton demo Demo

Slide 14

Slide 14 text

$ composer create-project symfony/skeleton demo Demo

Slide 15

Slide 15 text

$ composer create-project symfony/skeleton demo Demo

Slide 16

Slide 16 text

$ tree -I vendor $ find . -type f | wc -l Symfony 4 is lightweight Only 13 files vs 31 SE 2503 total vs 8867 SE -70%

Slide 17

Slide 17 text

New directory structure • Less depth, easier to navigate • Non-PHP files in their own directories (assets/, templates/) • Decoupled from Symfony (assets/, src/, templates/, public/)

Slide 18

Slide 18 text

https://github.com/symfony/recipes/ symfony/framework-bundle/3.3 Demo

Slide 19

Slide 19 text

symfony.lock

Slide 20

Slide 20 text

Recipes repositories https://github.com/symfony/recipes Curated recipes by Symfony core team https://github.com/symfony/recipes-contrib Open to all contributions 150+ recipes

Slide 21

Slide 21 text

Symfony Bot Validates contributions

Slide 22

Slide 22 text

Symfony Bot Let’s you test a recipe before merging

Slide 23

Slide 23 text

Symfony Bot Auto-merge pull requests

Slide 24

Slide 24 text

$ composer show | wc -l Demo Only 21 deps vs 38 + 50 = 88 SE

Slide 25

Slide 25 text

Symfony Standard Edition Monolog Bundle SwiftMailer Bundle Polyfill Util Polyfill PHP 7.0 Polyfill PHP 5.6 Polyfill Mbstring Polyfill Intl ICU Polyfill APCu PHPUnit Bridge Debug Bundle Framework Bundle Security Bundle Twig Bundle WebProfiler Bundle WebServer Bundle Doctrine Bridge Monolog Bridge Twig Bridge Monolog Doctrine (11) SecurityChecker Generator Bundle ParamHandler FrameworkExtra Bundle Distribution Bundle Asset BrowserKit Cache ClassLoader Config Console CssSelector Debug DependencyInjection DomCrawler Dotenv EventDispatcher ExpressionLanguage Filesystem Finder Form HttpFoundation HttpKernel Inflector Intl Ldap OptionsResolver Process PropertyAccess PropertyInfo Routing Security Serializer Stopwatch Templating Translation Validator VarDumper WebLink Workflow Yaml 4 bridges 15 librairies 11 bundles 42 components SwiftMailer

Slide 26

Slide 26 text

Symfony Flex / Symfony 4.0 Polyfill Mbstring Framework Bundle Cache Config Debug DependencyInjection Dotenv EventDispatcher Filesystem Finder HttpFoundation HttpKernel Routing Yaml 0 bridges 1 library 1 bundle 13 components Flex

Slide 27

Slide 27 text

Demo

Slide 28

Slide 28 text

$ ./bin/console Demo 13 commands vs 57 SE

Slide 29

Slide 29 text

$ git init $ git add . $ git commit -m"init" Demo

Slide 30

Slide 30 text

$ composer req maker:dev-master Demo

Slide 31

Slide 31 text

Aliases • Shortcuts for common packages (log, behat, phpunit, …) • Optimized for Symfony Components (no need to use the symfony/ prefix, just workflow, dom-crawler, …) • Opinionated choices (admin, api, orm, mailer, …)

Slide 32

Slide 32 text

Packs • Bundle several dependencies into a consistent set (debug, profiler, api, …) $ composer req debug

Slide 33

Slide 33 text

Discover Aliases and Packs https://symfony.sh/

Slide 34

Slide 34 text

Flex private repositories

Slide 35

Slide 35 text

$ composer config extra.symfony.id Register Flex private repositories

Slide 36

Slide 36 text

$ composer req maker:dev-master $ git diff config/bundles.php Symfony Maker Bundle

Slide 37

Slide 37 text

$ ./bin/console list make Symfony Maker Bundle

Slide 38

Slide 38 text

$ ./bin/console make:controller Symfony Maker Bundle

Slide 39

Slide 39 text

$ composer req annot Symfony Maker Bundle

Slide 40

Slide 40 text

$ ./bin/console make:controller DefaultController Symfony Maker Bundle

Slide 41

Slide 41 text

$ vim config/routes.yaml Symfony Maker Bundle

Slide 42

Slide 42 text

$ vim src/Controller/DefaultController.php Symfony Maker Bundle src/ is bundle-less

Slide 43

Slide 43 text

Application code is no longer divided into bundles.

Slide 44

Slide 44 text

Symfony 4 helps you
 grow your app
 with ease

Slide 45

Slide 45 text

$ composer req twig Adding Twig

Slide 46

Slide 46 text

Never define
 your service again*

Slide 47

Slide 47 text

Adding a Twig Extension Where do I store the Twig extension class? Which file do I need to change to register it? Which tag do I need to use? How do I declare a tag in YAML? Which interface/class do I need to implement/ extend? It’s too complex. What about doing it the dirty way and do it in the controller instead? hmm, ok

Slide 48

Slide 48 text

$ ./bin/console make:twig-extension Adding a Twig Extension Add your logic in the generated class… DONE!

Slide 49

Slide 49 text

Full Automation works for… • Twig extensions • Event listeners • Doctrine repositories • Commands • Voters • …

Slide 50

Slide 50 text

Beyond “Hello World” • Defining some models via Doctrine • Adding an API for my model • Managing data with an admin

Slide 51

Slide 51 text

$ composer req orm admin api Full stack really quick

Slide 52

Slide 52 text

$ ./bin/console make:entity Product $ vim config/packages/easy_admin.yaml Full stack really quick

Slide 53

Slide 53 text

$ vim .env DATABASE_URL="sqlite:///%kernel.project_dir%/var/ data.db" $ ./bin/console doctrine:database:create $ ./bin/console doctrine:schema:update --force Full stack really quick

Slide 54

Slide 54 text

DSNs parameters: database_host: 127.0.0.1 database_port: null database_name: symfony database_user: root database_password: null Symfony 2/3 Symfony 4 DATABASE_URL = "mysql://[email protected]:3306/symfony" MAILER_URL REDIS_URL …

Slide 55

Slide 55 text

It works! One line config change One annotation added

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

Symfony 4 with Flex recap • Auto-configuration for any Composer package • A new Maker bundle to simplify creating files • Support for Flex private repositories • No more boilerplate code, just business logic • Controllers and commands are services now • From micro to monolith • Meta-packages doing a lot for you out of the box Productivity boost! Better DX

Slide 58

Slide 58 text

More with Symfony 4 • Dependency injection without thinking about it • API Platform, the most advanced API system • Admin, simple and powerful • Symfony Encore, makes working with Webpack enjoyable Talk at Cluj! Talk at Cluj! Talk at Cluj!

Slide 59

Slide 59 text

More with Symfony 4 HTTP2 push support Inject secrets as parameters (Docker/K8s) Built-in PSR-3 logger Env vars where it makes sense DI simplified, classes as IDs PSR-11, PSR-6, PSR-16 out of the box Private services by default

Slide 60

Slide 60 text

Env/Debug mode // web/app_dev.php $kernel = new AppKernel('dev', true); $request = Request::createFromGlobals(); // ... // web/app.php $kernel = new AppKernel('prod', false); $request = Request::createFromGlobals(); // ... Symfony 2/3 Symfony 4 # .env APP_ENV = dev APP_DEBUG = 1 Enables the merge of
 app.php and app_dev.php to a single index.php

Slide 61

Slide 61 text

… which simplifies running commands # Symfony 2/3 $ ./bin/console foo:bar --env=prod —no-debug $ SYMFONY_ENV=prod SYMFONY_DEBUG=0 ./bin/console foo:bar # Symfony 4 $ ./bin/console foo:bar

Slide 62

Slide 62 text

Deprecating
 the obsolete

Slide 63

Slide 63 text

Long READMEs
 are a thing of the past WITHOUT Flex WITH Flex

Slide 64

Slide 64 text

Symfony Standard Edition • Not available for Symfony 4 • But still maintained for Symfony 2.7 -> 3.4 • EOL November 2020 Use Flex

Slide 65

Slide 65 text

Symfony Installer • Not available for Symfony 4 • But still maintained for Symfony 2.7 -> 3.4 • EOL November 2020 Use plain Composer and Flex

Slide 66

Slide 66 text

symfony/symfony as a dep • Won’t be enforced • But strongly not recommended • Won’t be removed as still the best way to manage the project Use explicit dependencies

Slide 67

Slide 67 text

Silex • New Symfony features not supported • EOL June 2018 Use Flex

Slide 68

Slide 68 text

symfony 1 • Last major release 7 years ago • End of life 5 years ago • End of infrastructure: December 2017 Use Symfony 2/3/4

Slide 69

Slide 69 text

No longer recommended • Symfony Standard Edition (EOL nov 2020) • Symfony Installer (EOL nov 2020) • symfony/symfony as a Composer dep (EOL nov 2020) • Silex (EOL june 2018) • symfony 1 (EOL dec 2017)

Slide 70

Slide 70 text

https://symfony.com/4

Slide 71

Slide 71 text

What’s next?

Slide 72

Slide 72 text

needs you

Slide 73

Slide 73 text

5 initiatives to grow Led by the community Supported by the Core Team And SensioLabs

Slide 74

Slide 74 text

5 new initiatives … to grow the community

Slide 75

Slide 75 text

Upgrade to 4 … all Symfony bundles and the ecosystem

Slide 76

Slide 76 text

Recipes Team … to review, approve, and merge contributions

Slide 77

Slide 77 text

Security Team … to manage the whole process

Slide 78

Slide 78 text

Interested? [email protected]

Slide 79

Slide 79 text

Integrations … to provide higher-level integrations

Slide 80

Slide 80 text

Current “integrations”, small and big • Monolog • Gmail support in semantic configuration • Assetic / Encore • Bootstrap 3 / 4

Slide 81

Slide 81 text

Some “random” ideas • Search engine: Algolia, ElasticSearch • Multi-factor authentication (Google Authenticator) / SAML • Structured logs • VueJS • Queues / Workers • Transactional email providers (Mailgun, Postmark, …) • Payment gateways (Stripe) • …

Slide 82

Slide 82 text

Diversity …scholarship, mentorship, …

Slide 83

Slide 83 text

Thank you!