Slide 1

Slide 1 text

@saro0h A year of Sarah Khalil

Slide 2

Slide 2 text

A little disclaimer

Slide 3

Slide 3 text

A little disclaimer E_TOO_MANY_NEWS

Slide 4

Slide 4 text

A little disclaimer E_TOO_MANY_NEWS You won’t remember everything

Slide 5

Slide 5 text

A little disclaimer E_TOO_MANY_NEWS You won’t remember everything Relax Enjoy as much as you can "

Slide 6

Slide 6 text

A little disclaimer E_TOO_MANY_NEWS You won’t remember everything Relax Enjoy as much as you can " Mission: Adopt Symfony 4!

Slide 7

Slide 7 text

Between decem ber 2016 & m arch 2017 https://speakerdeck.com/saro0h/symfonylive-paris-quoi-de-neuf-depuis-1-an

Slide 8

Slide 8 text

What’s the plan?

Slide 9

Slide 9 text

What’s the plan? Community

Slide 10

Slide 10 text

What’s the plan? Community Some code 3.3 3.4

Slide 11

Slide 11 text

What’s the plan? Community Some code 3.3 3.4 A little of 4

Slide 12

Slide 12 text

What’s the plan? Community Some code 3.3 3.4 A little of 4

Slide 13

Slide 13 text

Community

Slide 14

Slide 14 text

The Core team: New members Robin Chalas (@chalasr) Maxime Steinhausser (@ogizanagi)

Slide 15

Slide 15 text

The Core team: Thank you so much guys! # Bernhard Schussek (@webmozart) Abdellatif Ait Boudad (@aitboudad)

Slide 16

Slide 16 text

Pull Requests & Issues since last SymfonyCon

Slide 17

Slide 17 text

Pull Requests & Issues since last SymfonyCon $ $ $ $ $ $

Slide 18

Slide 18 text

Pull Requests & Issues since last SymfonyCon $ $ $ $ $ $ $ " %

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

Let’s see some code! 3.3 3.4

Slide 22

Slide 22 text

x.x Link to have a look later Some explanations Since which version What’s that about?

Slide 23

Slide 23 text

Form and Validator components

Slide 24

Slide 24 text

Form improvements New HTML5 types: • TelType (obvi ) • ColorType (color picker) • And some more! )* 3.4 http://symfony.com/blog/new-in-symfony-3-4-disable-global-form-themes http://symfony.com/blog/new-in-symfony-3-4-form-improvements http://symfony.com/blog/new-in-symfony-3-4-bootstrap-4-form-theme

Slide 25

Slide 25 text

Form improvements New HTML5 types: • TelType (obvi ) • ColorType (color picker) • And some more! )* 3.4 http://symfony.com/blog/new-in-symfony-3-4-disable-global-form-themes http://symfony.com/blog/new-in-symfony-3-4-form-improvements http://symfony.com/blog/new-in-symfony-3-4-bootstrap-4-form-theme

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

debug:form command • Lists form types, service types, extensions and guessers. • Get precise information about a type. • Get information by passing the type and an option name. 3.4 http://symfony.com/blog/new-in-symfony-3-4-debug-form-command

Slide 29

Slide 29 text

Validation improvement: Group validation in embedded object 3.4 class Author { /** @Assert\NotBlank */ protected $firstName; /** @Assert\Valid(groups={"basic"}) */ protected $address; } class Address { /** @Assert\NotBlank(groups={"basic"}) */ protected $street; /** @Assert\Length(max = 5) */ protected $zipCode; } http://symfony.com/blog/new-in-symfony-3-4-groups-support-for-the-valid-constraint

Slide 30

Slide 30 text

Validation improvement: new panel (1/2) 3.4 http://symfony.com/blog/new-in-symfony-3-4-validator-information-in-the-symfony-profiler

Slide 31

Slide 31 text

Validation improvement: new panel (2/2) 3.4 http://symfony.com/blog/new-in-symfony-3-4-validator-information-in-the-symfony-profiler

Slide 32

Slide 32 text

Validation improvement: new panel (2/2) 3.4 http://symfony.com/blog/new-in-symfony-3-4-validator-information-in-the-symfony-profiler

Slide 33

Slide 33 text

Validation improvement: new panel (2/2) 3.4 http://symfony.com/blog/new-in-symfony-3-4-validator-information-in-the-symfony-profiler

Slide 34

Slide 34 text

Developer eXperience improvements

Slide 35

Slide 35 text

3.3

Slide 36

Slide 36 text

Prefix in the route name use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; /** * @Route("/blog", name="blog_") */ class BlogController extends Controller { /** * @Route("/", defaults={"page": "1"}, name="index") * @Route("/page/{page}", name="index_paginated") */ public function indexAction($page, $_format) { ... } /** * @Route("/posts/{slug}", name="post") */ public function showAction(Post $post) { ... } } • blog_index • blog_index_paginated • blog_post http://symfony.com/blog/new-in-symfony-3-4-prefix-all-controller-route-names 3.4

Slide 37

Slide 37 text

Get the project root directory http://symfony.com/blog/new-in-symfony-3-3-a-simpler-way-to-get-the-project-root-directory %kernel.root_dir%/../web/ Before %kernel.project_dir%/web/ After 3.3

Slide 38

Slide 38 text

debug:autowiring command 3.4 http://symfony.com/blog/new-in-symfony-3-4-debug-autowiring-command

Slide 39

Slide 39 text

About command http://symfony.com/blog/new-in-symfony-3-3-about-command 3.3

Slide 40

Slide 40 text

Translation: Support of XLIFF 2.0 notes new true user login original-content translated-content http://symfony.com/blog/new-in-symfony-3-4-added-support-for-xliff-2-0-notes 3.4

Slide 41

Slide 41 text

PHPUnit tests: Better code coverage reports (1/2) • The code coverage = executed code. 3.4 Before http://symfony.com/blog/new-in-symfony-3-4-better-code-coverage-reports

Slide 42

Slide 42 text

PHPUnit tests: Better code coverage reports (1/2) • The code coverage = executed code. 3.4 Before http://symfony.com/blog/new-in-symfony-3-4-better-code-coverage-reports

Slide 43

Slide 43 text

PHPUnit tests: Better code coverage reports (1/2) • The code coverage = executed code. 3.4 • By hand, add @covers to specify what’s covered. Before http://symfony.com/blog/new-in-symfony-3-4-better-code-coverage-reports

Slide 44

Slide 44 text

PHPUnit tests: Better code coverage reports (1/2) • The code coverage = executed code. 3.4 • By hand, add @covers to specify what’s covered. Before http://symfony.com/blog/new-in-symfony-3-4-better-code-coverage-reports

Slide 45

Slide 45 text

PHPUnit tests: Better code coverage reports (2/2) 3.4 • Guesses the test class App\Tests\FooTest exists for App\Foo. • Adds @covers on classes that can be guessed. • You can do your own Listener if you don’t follow conventions. http://symfony.com/blog/new-in-symfony-3-4-better-code-coverage-reports After

Slide 46

Slide 46 text

Workflow

Slide 47

Slide 47 text

New twig functions {% if workflow_has_marked_place(cart, 'paid') %} ... {% endif %} http://symfony.com/blog/new-in-symfony-3-3-workflow-improvements {{ workflow_marked_places(post)|join(',') }} Check if the given object has the given state Get all possible places for a given object 3.3

Slide 48

Slide 48 text

Security

Slide 49

Slide 49 text

UserPasswordEncoderCommand improved 3.3 https://symfony.com/blog/new-in-symfony-3-3-securitybundle-improvements

Slide 50

Slide 50 text

Firewall listener • Only executed listeners are loaded, just by upgrading! • And we get more info about execution of listeners: 3.4

Slide 51

Slide 51 text

Improved impersonation • In the log we get impersonator_username along with user provider and the impersonated username. • More info in the WDT 3.4 http://symfony.com/blog/new-in-symfony-3-4-user-impersonation-improvements

Slide 52

Slide 52 text

Supports of Argon2i password hasher • You need first to: • either run your Symfony app with PHP 7.2 • or install the Libsodium PHP extension on your server • or install libsodium-php library to your project • Then: 3.4 # app/config/security.yml security: # ... encoders: Symfony\Component\Security\Core\User\User: algorithm: 'argon2i' http://symfony.com/blog/new-in-symfony-3-4-argon2i-password-hasher

Slide 53

Slide 53 text

use Symfony\Component\Security\Guard\AbstractGuardAuthenticator; class TokenAuthenticator extends AbstractGuardAuthenticator { public function getCredentials(Request $request) { if (!$token = $request->headers->get('X-AUTH-TOKEN')) { return null; } return ['token' => $token]; } } class TokenAuthenticator extends AbstractGuardAuthenticator { public function supports(Request $request) { return $request->headers->has('X-AUTH-TOKEN'); } public function getCredentials(Request $request) { return ['token' => $request->headers->get('X-AUTH-TOKEN')]; } } If returns null, you’ll get an exception. Before After

Slide 54

Slide 54 text

Performance improvement

Slide 55

Slide 55 text

Routing component: Faster routing Lots of micro improvements made to the URL matching process In an app that have 900 routes from 7.5ms to 2.5ms Interesting for app having lots of routes http://symfony.com/blog/new-in-symfony-3-3-faster-routing 3.3

Slide 56

Slide 56 text

2 new components

Slide 57

Slide 57 text

WebLink component • Specifications implementation: HTML5 Links, Preload, Resource hints • Assets preloading and prefetch (HTTP 2) • links between resources • HTTP/2 pushes http://symfony.com/blog/new-in-symfony-3-3-weblink-component Symfony\Bridge\Twig\Extension\WebLinkExtension 3.3

Slide 58

Slide 58 text

Webpack Encore component http://symfony.com/blog/introducing-webpack-encore-for-asset-management Symfony\Bridge\Twig\Extension\WebLinkExtension Manages assets (replaces Assetic) Webpack overlay CSS and Javascript processing Helps with the fastidious configuration 3.3

Slide 59

Slide 59 text

https://symfony.com/doc/current/service_container/3.3-di-changes.html

Slide 60

Slide 60 text

Let’s see 5 of them

Slide 61

Slide 61 text

Let’s see 5 of them

Slide 62

Slide 62 text

PSR-4 based Service Discovery services: AppBundle\: resource: ../src/{Controller,Command} http://symfony.com/blog/new-in-symfony-3-3-psr-4-based-service-discovery services: AppBundle\: resource: '../../src/AppBundle/*' exclude: '../../src/AppBundle/{AppBundle.php,Entity}' 3.3

Slide 63

Slide 63 text

All services are private by default • Inject the container and get service(s) from there bad practice • Hides real dependencies • Coupled to external config • Hard to test • Hard to review… • No need to have public services anymore (most of the cases). 3.4 http://symfony.com/blog/new-in-symfony-3-4-services-are-private-by-default

Slide 64

Slide 64 text

Local service binding (1/2) 3.4 services: # … App\Some\Service1: $projectDir: '%kernel.project_dir%' App\Some\Service2: $projectDir: '%kernel.project_dir%' App\Some\Service3: $projectDir: '%kernel.project_dir%' Before After services: _defaults: # … bind: $projectDir: '%kernel.project_dir%' http://symfony.com/blog/new-in-symfony-3-4-local-service-binding

Slide 65

Slide 65 text

Local binding (2/2) services: _defaults: bind: BarInterface: '@normal_bar_service' # ... special case for Foo: bind: BarInterface: '@special_bar_service' 3.4 http://symfony.com/blog/new-in-symfony-3-4-local-service-binding

Slide 66

Slide 66 text

Environment variables: very cool processing stuff (1/3) • Type cast (int, bool, float & string) • Resolve 3.4 parameters: # roughly equivalent to "(int) getenv('DATABASE_PORT')" app.connection.port: '%env(int:DATABASE_PORT)%' parameters: project_dir: '/foo/bar' env(DB): 'sqlite://%%project_dir%%/var/data.db' db_dsn: '%env(resolve:DB)%' http://symfony.com/blog/new-in-symfony-3-4-advanced-environment-variables

Slide 67

Slide 67 text

Environment variables: very cool processing stuff (2/3) • File & Json • Base64 • Const 3.4 parameters: env(SECRETS_FILE): '/etc/secure/example.com/secrets.json' app.secrets: '%env(json:file:SECRETS_FILE)%' parameters: env(SOME_VALUE): 'NWE3OWExYzg2NmVmZWY5Y2ExODAwZjk3MWQ2ODlmM2U=' app.some_value: '%env(base64:SOME_VALUE)%' parameters: env(NUM_ITEMS): 'App\\Entity\\BlogPost::NUM_ITEMS' app.num_items: '%env(constant:NUM_ITEMS)%'

Slide 68

Slide 68 text

Environment variables: very cool processing stuff (3/3) 3.4 And you can create your own processor! http://symfony.com/blog/new-in-symfony-3-4-advanced-environment-variables

Slide 69

Slide 69 text

Environment variables: very cool processing stuff (3/3) 3.4 And you can create your own processor! http://symfony.com/blog/new-in-symfony-3-4-advanced-environment-variables

Slide 70

Slide 70 text

Lazy loaded commands All commands needed to be instantiated to be registered. 3.4 Before After Make it lazy loaded by adding: app.command.complex_command: # ... tags: - { name: console.command, command: app:my-command } http://symfony.com/blog/new-in-symfony-3-4-lazy-commands

Slide 71

Slide 71 text

Just 2 more!

Slide 72

Slide 72 text

Trusted proxies: trusted_proxies parameter removed http://symfony.com/blog/fixing-the-trusted-proxies-configuration-for-symfony-3-3 Before After # app/config/config.yml framework: # ... trusted_proxies: [192.0.0.1, 10.0.0.0/8] // app.php $kernel = new AppKernel('prod', false); Request::setTrustedProxies( ['192.0.0.1', ’10.0.0.0/8’], Request::HEADER_FORWARDED ); $request = Request::createFromGlobals(); 3.3

Slide 73

Slide 73 text

Assets: provide request context in console 3.4 http://symfony.com/blog/new-in-symfony-3-4-default-request-context-for-assets # app/config/parameters.yml asset.request_context.base_path: '/subfolder' asset.request_context.secure: false asset(‘/foo/image.jpg’) /subfolder/foo/image.jpg

Slide 74

Slide 74 text

New way of developing with 4

Slide 75

Slide 75 text

Symfony Flex http://symfony.com/blog/symfony-4-a-new-way-to-develop-applications

Slide 76

Slide 76 text

Have the minimum to begin easily with a light app • Symfony 4 === Features of 3.4! • Preparing the future: • PHP based config for everything (to avoid having to install yaml dependency) http://symfony.com/blog/new-in-symfony-3-4-php-based-configuration-for-services-and-routes • Simpler logger http://symfony.com/blog/new-in-symfony-3-4-minimalist-psr-3-logger • …

Slide 77

Slide 77 text

About Bundle Inheritance: It’s gone! • No more bundles in Symfony 4 • The inheritance for controllers, routes, templates, services… is still possible! • Use solutions that doesn’t involve bundles http://symfony.com/blog/new-in-symfony-3-4-deprecated-bundle-inheritance

Slide 78

Slide 78 text

Let’s help to get there! • Please take time to test the version 4. • Documentation on Symfony 4 evolutions needs to be completed. • Bundles needs to become Symfony 4 compatible (have a at the Google sheet). • Create recipes for these bundles. https://symfony.com/blog/helping-prepare-for-symfony-4-bundle-support 4.0

Slide 79

Slide 79 text

Give help: Make a bundle compatible with Symfony 4 • First steps: • In composer.json file, for any symfony/* lines, add |^4.0 to it. • In the .travis.yml file, make it test against Symfony 4. • Then: • Submit your pull request. • See if there are failures. To fix them https://symfony.com/blog/helping-prepare-for-symfony-4-bundle-support 4.0

Slide 80

Slide 80 text

https://github.com/symfony/symfony/blob/master/UPGRADE-4.0.md

Slide 81

Slide 81 text

No content

Slide 82

Slide 82 text

No content

Slide 83

Slide 83 text

No content

Slide 84

Slide 84 text

No content

Slide 85

Slide 85 text

No content

Slide 86

Slide 86 text

@catlannister Get more involved to get to learn more! ♥

Slide 87

Slide 87 text

@catlannister Get more involved to get to learn more! ♥