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

Cartographing Symfony

Cartographing Symfony

This talk takes a look at Symfony Components from a package design perspective. We first categorize the components in functional layers and then take a closer look at how those layers are used by analyzing the package dependents. From there we take a look at package design principles and how they affect both the packages itself and their documentation and finally we discuss common questions around Symfony components.

Denis Brumann

February 04, 2021
Tweet

More Decks by Denis Brumann

Other Decks in Programming

Transcript

  1. Cartographing Symfony
    Making sense of the Symfony Components when used
    standalone or in full-stack

    View Slide

  2. View Slide

  3. Symfony 2.0
    Full List of Components
    BrowserKit

    ClassLoader

    Config

    Console

    CssSelector

    DependencyInjection

    DomCrawler

    EventDispatcher

    Filesystem

    Finder

    Form

    HttpFoundation

    HttpKernel

    Locale

    Process

    Routing

    Security

    Serializer

    Templating

    Translation

    Validator

    Yaml
    22 components

    View Slide

  4. Symfony 5.2
    Full List of Components
    Asset

    BrowserKit

    Cache

    Config

    Console

    CssSelector

    DependencyInjection

    DomCrawler

    Dotenv

    ErrorHandler

    EventDispatcher

    ExpressionLanguage

    Filesystem

    Finder

    Form

    HttpClient

    HttpFoundation

    HttpKernel

    Inflector

    Intl

    Ldap

    Lock

    Mailer

    Messenger

    Mime

    Notifier

    OptionsResolver

    Process

    PropertyAccess

    PropertyInfo

    RateLimiter

    Routing

    Security

    Semaphore

    Serializer

    Stopwatch

    String

    Templating

    Translation

    Uid

    Validator

    VarDumper

    VarExporter

    WebLink

    Workflow

    Yaml

    26 NEW components

    *compared to Symfony 2.0

    View Slide

  5. core features utility features
    application features framework features

    View Slide

  6. 74.336
    Dependents Overall

    View Slide

  7. Core Features
    Asset
    BrowserKit
    Cache
    Config
    CssSelector
    DependencyInjection
    DomCrawler
    Console
    ErrorHandler
    EventDispatcher
    ExpressionLanguage
    Filesystem
    DotEnv
    Form
    HttpClient
    HttpFoundation
    Inflector
    Intl
    Ldap
    HttpKernel
    Mailer
    Messenger
    Mime
    Notifier
    Lock
    Finder
    Process
    PropertyAccess
    PropertyInfo
    Routing
    Security
    Semaphore
    RateLimiter
    Stopwatch
    String
    Templating
    Translation
    Serializer
    OptionsResolver
    VarExporter
    Weblink
    Workflow
    VarDumper
    Uid
    Validator
    Yaml

    View Slide

  8. Core Features
    Improve on core PHP functionality

    • HttpFoundation provides OOP on top of superglobals

    • String provides clear API around mb_* and other string functions

    • Uid provides OOP for handling UUID/ULID-strings

    • VarExport works around limitations of clone

    • …

    View Slide

  9. Core Features
    Asset
    BrowserKit
    Cache
    Config
    CssSelector
    DependencyInjection
    DomCrawler
    Console
    ErrorHandler
    EventDispatcher
    ExpressionLanguage
    Filesystem
    DotEnv
    Form
    HttpClient
    HttpFoundation
    Inflector
    Intl
    Ldap
    HttpKernel
    Mailer
    Messenger
    Mime
    Notifier
    Lock
    Finder
    Process
    PropertyAccess
    PropertyInfo
    Routing
    Security
    Semaphore
    RateLimiter
    Stopwatch
    String
    Templating
    Translation
    Serializer
    OptionsResolver
    VarExporter
    Weblink
    Workflow
    VarDumper
    Uid
    Validator
    Yaml

    View Slide

  10. Core Features
    Filesystem

    View Slide

  11. 12.187
    Dependents on Core Features

    View Slide

  12. View Slide

  13. View Slide

  14. Utility Features
    Asset
    BrowserKit
    Cache
    Config
    CssSelector
    DependencyInjection
    DomCrawler
    Console
    ErrorHandler
    EventDispatcher
    ExpressionLanguage
    Filesystem
    DotEnv
    Form
    HttpClient
    HttpFoundation
    Inflector
    Intl
    Ldap
    HttpKernel
    Mailer
    Messenger
    Mime
    Notifier
    Lock
    Finder
    Process
    PropertyAccess
    PropertyInfo
    Routing
    Security
    Semaphore
    RateLimiter
    Stopwatch
    String
    Templating
    Translation
    Serializer
    OptionsResolver
    VarExporter
    Weblink
    Workflow
    VarDumper
    Uid
    Validator
    Yaml

    View Slide

  15. Utility Features
    Components that can be used outside of Symfony, e.g. in libraries

    • Process

    • Finder

    • EventDispatcher

    View Slide

  16. Utility Features
    Asset
    BrowserKit
    Cache
    Config
    CssSelector
    DependencyInjection
    DomCrawler
    Console
    ErrorHandler
    EventDispatcher
    ExpressionLanguage
    Filesystem
    DotEnv
    Form
    HttpClient
    HttpFoundation
    Inflector
    Intl
    Ldap
    HttpKernel
    Mailer
    Messenger
    Mime
    Notifier
    Lock
    Finder
    Process
    PropertyAccess
    PropertyInfo
    Routing
    Security
    Semaphore
    RateLimiter
    Stopwatch
    String
    Templating
    Translation
    Serializer
    OptionsResolver
    VarExporter
    Weblink
    Yaml
    VarDumper
    Uid
    Validator
    Workflow

    View Slide

  17. Utility Features
    Finder

    View Slide

  18. Utility Features
    Finder

    View Slide

  19. 37.240
    Dependents on Utility Features

    View Slide

  20. View Slide

  21. Application Features
    Asset
    BrowserKit
    Cache
    Config
    CssSelector
    DependencyInjection
    DomCrawler
    Console
    ErrorHandler
    EventDispatcher
    ExpressionLanguage
    Filesystem
    DotEnv
    Form
    HttpClient
    HttpFoundation
    Inflector
    Intl
    Ldap
    HttpKernel
    Mailer
    Messenger
    Mime
    Notifier
    Lock
    Finder
    Process
    PropertyAccess
    PropertyInfo
    Routing
    Security
    Semaphore
    RateLimiter
    Stopwatch
    String
    Templating
    Translation
    Serializer
    OptionsResolver
    VarExporter
    Weblink
    Yaml
    VarDumper
    Uid
    Validator
    Workflow

    View Slide

  22. Application Features
    Application components, that usually work on top of the framework, core or
    utility features

    • Messenger supports Mailer optionally uses Serializer

    • Form relies on Validation (optionally), HttpFoundation and OptionResolver

    View Slide

  23. Application Features
    Asset
    BrowserKit
    Cache
    Config
    CssSelector
    DependencyInjection
    DomCrawler
    Console
    ErrorHandler
    EventDispatcher
    ExpressionLanguage
    Filesystem
    DotEnv
    Form
    HttpClient
    HttpFoundation
    Inflector
    Intl
    Ldap
    HttpKernel
    Mailer
    Messenger
    Mime
    Notifier
    Lock
    Finder
    Process
    PropertyAccess
    PropertyInfo
    Routing
    Security
    Semaphore
    RateLimiter
    Stopwatch
    String
    Templating
    Translation
    Serializer
    OptionsResolver
    VarExporter
    Weblink
    Yaml
    VarDumper
    Uid
    Validator
    Workflow

    View Slide

  24. Application Features
    Messenger

    View Slide

  25. 9.627
    Dependents on Application Features

    View Slide

  26. View Slide

  27. Framework Features
    Asset
    BrowserKit
    Cache
    Config
    CssSelector
    DependencyInjection
    DomCrawler
    Console
    ErrorHandler
    EventDispatcher
    ExpressionLanguage
    Filesystem
    DotEnv
    Form
    HttpClient
    HttpFoundation
    Inflector
    Intl
    Ldap
    HttpKernel
    Mailer
    Messenger
    Mime
    Notifier
    Lock
    Finder
    Process
    PropertyAccess
    PropertyInfo
    Routing
    Security
    Semaphore
    RateLimiter
    Stopwatch
    String
    Templating
    Translation
    Serializer
    OptionsResolver
    VarExporter
    Weblink
    Yaml
    VarDumper
    Uid
    Validator
    Workflow

    View Slide

  28. Framework Features
    Components that primarily build up Symfony as an application framework

    • HttpKernel ties config, routing, error handling for web app together

    • Config loads human processable config files and validates them

    • DependencyInjection takes config and creates PHP service configuration

    • Routing provides a way to determine which Controller should be used

    • ErrorHandler centralizes & streamlines error-/exception-handling

    • Templating renders output for Response

    View Slide

  29. Framework Features
    Asset
    BrowserKit
    Cache
    Config
    CssSelector
    DependencyInjection
    DomCrawler
    Console
    ErrorHandler
    EventDispatcher
    ExpressionLanguage
    Filesystem
    DotEnv
    Form
    HttpClient
    HttpFoundation
    Inflector
    Intl
    Ldap
    HttpKernel
    Mailer
    Messenger
    Mime
    Notifier
    Lock
    Finder
    Process
    PropertyAccess
    PropertyInfo
    Routing
    Security
    Semaphore
    RateLimiter
    Stopwatch
    String
    Templating
    Translation
    Serializer
    OptionsResolver
    VarExporter
    Weblink
    Yaml
    VarDumper
    Uid
    Validator
    Workflow

    View Slide

  30. Framework Features
    DependencyInjection

    View Slide

  31. 15.282
    Dependents on Framework Features
    *
    * Symfony Bundles

    View Slide

  32. View Slide

  33. View Slide

  34. Framework Features
    Asset
    BrowserKit
    Cache
    Config
    CssSelector
    DependencyInjection
    DomCrawler
    Console
    ErrorHandler
    EventDispatcher
    ExpressionLanguage
    Filesystem
    DotEnv
    Form
    HttpClient
    HttpFoundation
    Inflector
    Intl
    Ldap
    HttpKernel
    Mailer
    Messenger
    Mime
    Notifier
    Lock
    Finder
    Process
    PropertyAccess
    PropertyInfo
    Routing
    Security
    Semaphore
    RateLimiter
    Stopwatch
    String
    Templating
    Translation
    Serializer
    OptionsResolver
    VarExporter
    Weblink
    Yaml
    VarDumper
    Uid
    Validator
    Workflow

    View Slide

  35. core

    features
    utility

    features
    application

    features
    framework

    features
    less coupled more coupled

    View Slide

  36. core

    features
    utility

    features
    easier to use harder to use
    application

    features
    framework

    features

    View Slide

  37. core

    features
    utility

    features
    easier to use standalone harder to use standalone
    application

    features
    framework

    features

    View Slide

  38. View Slide

  39. View Slide

  40. View Slide

  41. Symfony 2.8
    • Assets

    • ExpressionLanguage

    • Intl

    • Ldap

    • OptionsResolver

    • PropertyInfo

    View Slide

  42. Symfony 3.4
    • Cache

    • DotEnv

    • Inflector

    • WebLink

    • Workflow

    View Slide

  43. Symfony 4.4
    • ErrorHandler

    • HttpClient

    • Messenger

    • Mime

    • Notifier

    • VarExporter

    View Slide

  44. Symfony 5.2
    • RateLimiter

    • Semaphore

    • String

    • Uid

    View Slide

  45. https://matthiasnoback.nl/book/principles-of-package-design/

    View Slide

  46. The Release/Reuse Equivalence Principle
    The Common Reuse Principle
    The Common Closure Principle
    The Acyclic Dependencies Principle
    The Stable Dependencies Principle
    The Stable Abstractions Principle

    View Slide

  47. ISO/IEC 25010

    View Slide

  48. View Slide

  49. Decoupled?!
    Using Symfony Components standalone is really difficult!

    View Slide

  50. View Slide

  51. View Slide

  52. View Slide

  53. View Slide

  54. View Slide

  55. View Slide

  56. View Slide

  57. View Slide

  58. View Slide

  59. View Slide

  60. View Slide

  61. View Slide

  62. View Slide

  63. View Slide

  64. NIH
    Why doesn’t Symfony just reuse existing libraries?

    View Slide

  65. View Slide

  66. View Slide

  67. View Slide

  68. Where is
    Waldo?
    Why doesn’t Symfony have feature X, Y or Z?

    View Slide

  69. View Slide

  70. View Slide