Slide 1

Slide 1 text

@nicolasgrekas #DrupalConPrague Drupal 10 from the pov of a Symfony 6 core-contributor Nicolas Grekas

Slide 2

Slide 2 text

@nicolasgrekas General Manager at Symfony Corp. Core-team member since 2014 ~3000 PRs sent to symfony/symfony

Slide 3

Slide 3 text

Symfony TL;DR

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

• Core-Team • Security Policy • Welcoming Spaces • CARE Team • Friendly CI Community Principles

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

https://dri.es/

Slide 10

Slide 10 text

Drupal 10 From Symfony 4.4 to 6.2

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

PHP >= 8.1 • Native return types • (nested) Attributes • Enums • Serializable

Slide 13

Slide 13 text

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']

Slide 14

Slide 14 text

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']);

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

Symfony HttpFoundation RFC 8674 - Avoid objectionable content, as defined by the origin server $request->preferSafeContent(); // Prefer: safe $response->setContentSafe(); // Preference-Applied: safe // Vary: Prefer

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

Symfony DependencyInjection • #[Autowire('%foo%')] • #[TaggedIterator + TaggedLocator + AsTaggedItem] • #[AsDecorator + MapDecorated + .inner] • #[Target] • #[Required]

Slide 19

Slide 19 text

Symfony DependencyInjection • #[Autoconfigure] and #[AutoconfigureTag] • Expressions as service factories • Native lazy-loading services

Slide 20

Slide 20 text

Let’s run a barista

Slide 21

Slide 21 text

Let’s run a barista

Slide 22

Slide 22 text

Let’s run a barista

Slide 23

Slide 23 text

Let’s run a barista

Slide 24

Slide 24 text

Let’s run a barista

Slide 25

Slide 25 text

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)

Slide 26

Slide 26 text

Undergo change or be the change • Be creative • Grow your roots and standardize • Embrace deprecations • And delete code!

Slide 27

Slide 27 text

Kudos! D+S=<3

Slide 28

Slide 28 text

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