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

Drupal 10 from the pov of a Symfony 6 core-cont...

Drupal 10 from the pov of a Symfony 6 core-contributor

While Drupal 8 & 9 rely on Symfony 3.4 & 4.4 respectively, Drupal 10 is going to be based on Symfony 6.2. That's a nice a leap forward that will allow Drupalers to catch up on almost 3 years of innovation on Symfony's side \o/

In this presentation, we'll review the new features coming to core from Symfony that you could take advantage of. Think about more expressive/automated ways to do dependency-injection, using PHP 8 attributes to configure all-the-things, translation providers, safer sub-processes, etc.

So much new power-tools at your disposal that just wait to be learned about!

Avatar for Nicolas Grekas

Nicolas Grekas

September 22, 2022
Tweet

More Decks by Nicolas Grekas

Other Decks in Programming

Transcript

  1. Symfony OSS • Open Source Software since 2011 (v2) •

    Built for the web, built in PHP • The top-most used PHP components • The second top-most used PHP framework • 3 000 contributors • ~60 core components, ~200 packages • 14B cumulated downloads
  2. Designed for cheap upgrades Within the same major: The Backward

    Compatibility Promise Across major versions: The Continuous Upgrade Path TL;DR composer up symfony/* every 1 month Upgrade to the next “minor” every 6 months (in June and December) and fix deprecations Roadmap
  3. 1. Any planned break MUST issue a deprecation notice 2.

    Deprecating and upgrading must be done in the same PR 3. You should be able to upgrade Symfony XOR php Continuous Upgrade Path
  4. • Core-Team • Security Policy • Welcoming Spaces • CARE

    Team • Friendly CI Community Principles
  5. Cutting Edge Practices • v4.4 : Support for PHP 8.0,

    8.1 and 8.2(!) deprecation-less • v5.4 : Support new features of the language (attributes, enums) • v6.0 : Drop deprecated code • v6.1 : Use modern-style syntax • v6.1 : Better type declarations with native and generic types • v6.2 : Still WIP - More attributes Last 12 months • +8000 files modified -- +470/-430k files • +2000 PRs - 6/day • 400 features -- 700 bugs -- +900(!) minors
  6. Drupal 10 Core • Console • DependencyInjection • EventDispatcher •

    HttpFoundation • HttpKernel • Mime • Process • Routing • Serializer • String • Validator • VarExporter • VarDumper • Yaml • Twig • Cache • Clock • Dotenv • ErrorHandler • HttpClient • HtmlSanitizer • Mailer • Messenger • Notifier • Uid • Workflow
  7. Symfony String Object-oriented abstraction to deal with binary and Unicode

    strings u('Symfony is great')->slice(0, 7); // 'Symfony' Slugger $slugger->slug('Wôrķšƥáçè sèťtïñğš '); // 'Workspace-settings-smiley-cat' Inflector $inflector->singularize('teeth'); // ['tooth']
  8. Symfony Process Arrays for single processes new Process(['ls', '-lsa', $path])

    Prepared command-lines when needing a shell $process = Process::fromShellCommandline('ls -lsa "${:path}" | grep foo'); $process->run(null, ['path' => '/path/to/some/dir']);
  9. Symfony Routing #[Route( path: '/users/{id}', requirements: ['id' => Requirement::ULID] )]

    public const ULID = '[0-7][0-9A-HJKMNP-TV-Z]{25}'; public const DIGITS = '[0-9]+'; // ... # modules/custom/custom/coffee_shop/coffee_shop.routing.yml coffee_shop: resource: src/Controller/ type: attribute
  10. Symfony HttpFoundation RFC 8674 - Avoid objectionable content, as defined

    by the origin server $request->preferSafeContent(); // Prefer: safe $response->setContentSafe(); // Preference-Applied: safe // Vary: Prefer
  11. Symfony HttpKernel • Replace KernelEvent::isMasterRequest() by isMainRequest() • Add argument

    $catchThrowable to HttpKernel::__construct()? • #[AsController] - needs RegisterControllerArgumentLocatorsPass • #[Cache] - needs CacheAttributeListener • Value resolvers for DateTime, BackedEnum and Uid
  12. Symfony DependencyInjection • #[Autowire('%foo%')] • #[TaggedIterator + TaggedLocator + AsTaggedItem]

    • #[AsDecorator + MapDecorated + .inner] • #[Target] • #[Required]
  13. Put *.services.yml on a diet • Enable auto-discovery – RIP

    providers • Enable auto-configuration – RIP tags/passes • Enable controllers as services – RIP Drupal::service() • Enable custom value resolvers – at least enable the new ones in core • Enable #[Autowire('%env(FOO)%')] • Enable #[Route] • (Don’t force lowercase service ids) • (Document how to auto-invalidate the container from CLI)
  14. Undergo change or be the change • Be creative •

    Grow your roots and standardize • Embrace deprecations • And delete code!
  15. the general conference survey Flash the QR code OR It

    will be sent by email the Individual session surveys (located under each session description) 1 2