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

Pimcore Inspire 2021 - Symfony 5

Pimcore Inspire 2021 - Symfony 5

What's new in Symfony 5? Let's see together which features this new version offers.
Presentation given at Pimcore Inspire 2021.

Alexandre Daubois

November 19, 2021
Tweet

More Decks by Alexandre Daubois

Other Decks in Technology

Transcript

  1. 1

  2. 2

  3. 3

  4. 4

  5. 5.0 = 4.4 − deprecations + experimental 6.0 = 5.4

    − deprecations + experimental 7.0 = 6.4 − deprecations + experimental 8.0 = 7.4 − deprecations + experimental 9.0 = 8.4 − deprecations + experimental 7
  6. Semantic versioning Backward compatibility promise (all details here: ) Deprecations

    triggering: all breaks must lead to a warning first! https://symfony.com/doc/current/contributing/code/bc.html 8
  7. Support of PHP 8 & 8.1 features <?php namespace App\Model;

    use Symfony\Component\Validator\Constraints as Assert; class Entity { #[ Assert\NotBlank, Assert\Range(min: 3, max: 10), Assert\All([ new Assert\NotNull, new Assert\Range(min: 3), ]), ] public $property; // ... } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 10
  8. Notifier component <?php namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Notifier\ChatterInterface; use

    Symfony\Component\Notifier\Message\ChatMessage; use Symfony\Component\Routing\Annotation\Route; class ConfirmController extends AbstractController { #[Route('/confirm')] public function confirm(ChatterInterface $chatter) { $message = (new ChatMessage('Someone has confirmed their account.')) ->transport('slack'); $sentMessage = $chatter->send($message); // ... } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 11
  9. String component Object-oriented way to manipulate strings Unicode made easy

    (say hi to special chars and emojis! 👋) Incorporated slugger! // u(...) is equivalent to new UnicodeString(...) u('https://symfony.com')->startsWith('https'); // True u('iPhone 13 Pro')->endsWith('Pro'); // True u('https://twitter.com/alexdaubois')->containsAny('daubois'); // True u('https://github.com/alexandre-daubois')->replace('alexandre-daubois', 'sensiolabs'); // https://github.com/sensiolabs // And many more functions to split, join, truncate... /** Slugger in action */ $slugger = new AsciiSlugger(); $slug = $slugger->slug('Pimcore Inspire 2021!'); // $slug = 'pimcore-inspire-2021' 14
  10. Secrets management Easily manage sensitive information Splitted by environments Safely

    commit public encryption keys Smoothly use secrets like env var (%env(SECRET_NAME)%) Migrate all secrets in one command if the private key is compromised 15
  11. RateLimiter component Limit how frequently an event happens Many use

    cases! Choose discriminator (email, username, IP...) Straightforward configuration Multiple policies (fixed, sliding and token bucket) framework: rate_limiter: my_named_limiter: policy: 'fixed_window' limit: 1000 interval: '12 hours' 1 2 3 4 5 6 Example: create a limiter to authorize 1000 calls every 12 hours 16
  12. Translation Providers Plug in with services like Crowdin, Loco, Lokalise

    Easily upload and download translations framework: translator: providers: crowdin: dsn: 'crowdin://PROJECT_ID:API_TOKEN@ORGANIZATION_DOMAIN.default' domains: ['messages', 'validator'] locales: ['en', 'fr'] 1 2 3 4 5 6 7 # Push translations to Crowdin... $ php bin/console translation:push crowdin --force # ... and later, pull translators' work! $ php bin/console translation:pull crowdin --force Set up a few things (maybe with secrets?)... ... then run 2 commands. That's it! 17
  13. Big thanks to Nicolas Grekas for allowing me to take

    inspiration from his work on these slides! @nicolasgrekas 18
  14. 19