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

Symfony 4 - Let's get dangerous

Marko Kunic
November 08, 2017

Symfony 4 - Let's get dangerous

Symfony 4 is here soon, it is time to get ready, it is time to get dangerous. I tried to cover as much as I could and tried to pick most interesting topics.

Marko Kunic

November 08, 2017
Tweet

More Decks by Marko Kunic

Other Decks in Programming

Transcript

  1. @kunicmarko20
    Symfony 4
    Let’s get dangerous

    View Slide

  2. @kunicmarko20
    Symfony 3.4
    -
    Deprecated
    features
    Symfony 4
    =

    View Slide

  3. @kunicmarko20
    Symfony 3.4
    -
    Deprecated
    features
    Symfony 4
    =
    PHP ^5.5 PHP ^7.1

    View Slide

  4. @kunicmarko20
    Symfony Flex Symfony 4

    View Slide

  5. @kunicmarko20
    Symfony Flex

    View Slide

  6. @kunicmarko20
    ● Composer plugin
    ● Replaces Symfony Standard Edition
    ● Compose your Application
    ● Recipes (Official, Contrib)
    ● Depend on the individual Symfony Components
    ● Bundle-less Application
    ● New Directory structure
    ● Environment Variables
    ● Unified Web Front Controller
    ● Defining compiler passes in the kernel
    ● Symfony 3.3+

    View Slide

  7. @kunicmarko20
    Directory Structure

    View Slide

  8. @kunicmarko20
    Environment Variables

    View Slide

  9. @kunicmarko20
    ● Runtime Environment Variables

    View Slide

  10. @kunicmarko20

    View Slide

  11. @kunicmarko20
    ● Runtime Environment Variables
    ● Deprecated the SYMFONY__ environment variables

    View Slide

  12. @kunicmarko20
    Before
    After

    View Slide

  13. @kunicmarko20
    ● Runtime Environment Variables
    ● Deprecated the SYMFONY__ environment variables
    ● Advanced environment variables

    View Slide

  14. @kunicmarko20

    View Slide

  15. @kunicmarko20
    ● Runtime Environment Variables
    ● Deprecated the SYMFONY__ environment variables
    ● Advanced environment variables
    ● Dotenv component
    ● No more --env=prod --no-debug

    View Slide

  16. @kunicmarko20
    DI Container Changes

    View Slide

  17. @kunicmarko20
    ● Services are Loaded Automatically
    ● Type-hint instead of Service id
    ● Controllers are Registered as Services
    ● Auto-tagging with autoconfigure
    ● Services private by Default
    ● Named args
    ● Local service binding

    View Slide

  18. @kunicmarko20

    View Slide

  19. @kunicmarko20

    View Slide

  20. @kunicmarko20

    View Slide

  21. @kunicmarko20

    View Slide

  22. @kunicmarko20
    Workflow Component

    View Slide

  23. @kunicmarko20
    ● Workflow, State Machine
    ● Single/Multiple State
    ● Transitions
    ● Transition Events

    View Slide

  24. @kunicmarko20

    View Slide

  25. @kunicmarko20

    View Slide

  26. @kunicmarko20

    View Slide

  27. @kunicmarko20

    View Slide

  28. @kunicmarko20

    View Slide

  29. @kunicmarko20
    Transition Events
    ● Guard
    ● Leave
    ● Transition
    ● Enter
    ● Entered
    ● Announce
    ● workflow.[event]
    ● workflow.[workflow].[event]
    ● workflow.[workflow].[event].[transition]

    View Slide

  30. @kunicmarko20

    View Slide

  31. @kunicmarko20
    http://symfony-workflow-demo.herokuapp.com

    View Slide

  32. @kunicmarko20
    Want to know more?
    Knowing your state machines
    https://www.youtube.com/watch?v=S87111sM7y4
    by Tobias Nyholm @ SymfonyCon Berlin 2016

    View Slide

  33. @kunicmarko20
    Cache Component

    View Slide

  34. @kunicmarko20
    ● PSR-6: Caching Interface

    View Slide

  35. @kunicmarko20

    View Slide

  36. @kunicmarko20
    ● PSR-6: Caching Interface
    ● PSR-16: Common Interface for Caching
    Libraries

    View Slide

  37. @kunicmarko20

    View Slide

  38. @kunicmarko20
    ● PSR-6: Caching Interface
    ● PSR-16: Common Interface for Caching
    Libraries
    ● Tag-based invalidation

    View Slide

  39. @kunicmarko20

    View Slide

  40. @kunicmarko20
    Let’s implement Cache Component

    View Slide

  41. @kunicmarko20
    composer require snc/redis-bundle predis/predis

    View Slide

  42. @kunicmarko20

    View Slide

  43. @kunicmarko20

    View Slide

  44. @kunicmarko20

    View Slide

  45. @kunicmarko20

    View Slide

  46. @kunicmarko20

    View Slide

  47. @kunicmarko20

    View Slide

  48. @kunicmarko20

    View Slide

  49. @kunicmarko20
    What else has changed?

    View Slide

  50. @kunicmarko20
    ● User value resolver for controllers

    View Slide

  51. @kunicmarko20
    Before

    View Slide

  52. @kunicmarko20
    After

    View Slide

  53. @kunicmarko20
    ● User value resolver for controllers
    ● PHP constants in YAML files

    View Slide

  54. @kunicmarko20

    View Slide

  55. @kunicmarko20
    ● User value resolver for controllers
    ● PHP constants in YAML files
    ● Project root directory parameter

    View Slide

  56. @kunicmarko20
    %kernel.root_dir%/../web/

    View Slide

  57. @kunicmarko20
    %kernel.root_dir%/../web/

    View Slide

  58. @kunicmarko20
    %kernel.project_dir%/web/

    View Slide

  59. @kunicmarko20
    ● User value resolver for controllers
    ● PHP constants in YAML files
    ● Project root directory parameter
    ● Asset preloading with HTTP/2 Push

    View Slide

  60. @kunicmarko20
    Read more: https://dunglas.fr/2017/10/symfony-4-http2-push-and-preloading

    View Slide

  61. @kunicmarko20
    ● User value resolver for controllers
    ● PHP constants in YAML files
    ● Project root directory parameter
    ● Asset preloading with HTTP/2 Push
    ● Import config files with glob patterns

    View Slide

  62. @kunicmarko20

    View Slide

  63. @kunicmarko20
    ● User value resolver for controllers
    ● PHP constants in YAML files
    ● Project root directory parameter
    ● Asset preloading with HTTP/2 Push
    ● Import config files with glob patterns
    ● Lock Component

    View Slide

  64. @kunicmarko20

    View Slide

  65. @kunicmarko20
    ● User value resolver for controllers
    ● PHP constants in YAML files
    ● Project root directory parameter
    ● Asset preloading with HTTP/2 Push
    ● Import config files with glob patterns
    ● Lock component
    ● Deprecated bundle inheritance

    View Slide

  66. @kunicmarko20
    ● User value resolver for controllers
    ● PHP constants in YAML files
    ● Project root directory parameter
    ● Asset preloading with HTTP/2 Push
    ● Import config files with glob patterns
    ● Lock component
    ● Deprecated bundle inheritance
    ● Improved the overriding of templates

    View Slide

  67. @kunicmarko20

    View Slide

  68. @kunicmarko20
    ● User value resolver for controllers
    ● PHP constants in YAML files
    ● Project root directory parameter
    ● Asset preloading with HTTP/2 Push
    ● Import config files with glob patterns
    ● Lock component
    ● Deprecated bundle inheritance
    ● Improved the overriding of templates
    ● Better console exceptions

    View Slide

  69. @kunicmarko20
    Before
    After

    View Slide

  70. @kunicmarko20
    ● User value resolver for controllers
    ● PHP constants in YAML files
    ● Project root directory parameter
    ● Asset preloading with HTTP/2 Push
    ● Import config files with glob patterns
    ● Lock component
    ● Deprecated bundle inheritance
    ● Improved the overriding of templates
    ● Better console exceptions
    ● Lazy commands

    View Slide

  71. @kunicmarko20

    View Slide

  72. @kunicmarko20
    ● User value resolver for controllers
    ● PHP constants in YAML files
    ● Project root directory parameter
    ● Asset preloading with HTTP/2 Push
    ● Import config files with glob patterns
    ● Lock component
    ● Deprecated bundle inheritance
    ● Improved the overriding of templates
    ● Better console exceptions
    ● Lazy commands
    ● Improved comparison constraints

    View Slide

  73. @kunicmarko20

    View Slide

  74. @kunicmarko20
    ● User value resolver for controllers
    ● PHP constants in YAML files
    ● Project root directory parameter
    ● Asset preloading with HTTP/2 Push
    ● Import config files with glob patterns
    ● Lock component
    ● Deprecated bundle inheritance
    ● Improved the overriding of templates
    ● Better console exceptions
    ● Lazy commands
    ● Improved comparison constraints
    ● Groups support for the Valid constraint

    View Slide

  75. @kunicmarko20
    ● User value resolver for controllers
    ● PHP constants in YAML files
    ● Project root directory parameter
    ● Asset preloading with HTTP/2 Push
    ● Import config files with glob patterns
    ● Lock component
    ● Deprecated bundle inheritance
    ● Improved the overriding of templates
    ● Better console exceptions
    ● Lazy commands
    ● Improved comparison constraints
    ● Groups support for the Valid constraint
    ● Argon2i password hasher

    View Slide

  76. @kunicmarko20
    Similar Talks
    ● Symfony 4 & Symfony Flex - Core ideas, features and
    improvements by Victoria Quirante
    ● Symfony 4 Run-through by Kévin Dunglas
    ● Get ready for Symfony 4 by Christian Flothmann
    ● Getting ready for Symfony 4 by Denis Brumann

    View Slide

  77. @kunicmarko20
    The End

    View Slide