Share
Embed
Annual Pro sale · Save $30
Have presentations of your own?
Share with private links, password protection, and more control over your work.
Transcript
90 slides
-
Thomas Calvet - fancyweb L’expérience développeur dans Drupal 8 Drupalcamp
Paris 2019 Améliorons-la ! -
Developer experience 3 Drupalcamp Paris 2019 - L’expérience développeur dans
Drupal 8 : améliorons-la ! • Kind of the same concept than the User eXperience applied to development • The user is the developer • But we are more demanding • And the scope is larger -
Drupal DX has even more aspects 4 Drupalcamp Paris 2019
- L’expérience développeur dans Drupal 8 : améliorons-la ! • Several developer profiles • Site builder • Theme builder • Custom module maker -
So, whatisthe topic today? 5 Drupalcamp Paris 2019 - L’expérience
développeur dans Drupal 8 : améliorons-la ! -
This talk is about 6 Drupalcamp Paris 2019 - L’expérience
développeur dans Drupal 8 : améliorons-la ! • Your custom code • Daily development • Avoid repetitive tasks • Help new Drupal developers -
This talk is not about 7 Drupalcamp Paris 2019 -
L’expérience développeur dans Drupal 8 : améliorons-la ! • Admin part • Core architecture / code • Documentation • Contribution -
Examplesof DX features 8 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! -
Provide shortcuts 9 Drupalcamp Paris 2019 - L’expérience développeur dans
Drupal 8 : améliorons-la ! • Abstract implementations • Functions, methods, classes, traits • The goal is to hide a complexity -
Throw exceptions 10 Drupalcamp Paris 2019 - L’expérience développeur dans
Drupal 8 : améliorons-la ! • Handle common users mistakes • Be defensive • Throw an exception • With a useful message -
Simple things 11 Drupalcamp Paris 2019 - L’expérience développeur dans
Drupal 8 : améliorons-la ! • A small UI change • An up to date PHPDoc • Rename a test class • Etc. -
Whydoesitmatter? 12 Drupalcamp Paris 2019 - L’expérience développeur dans Drupal
8 : améliorons-la ! -
Why does it matter? 13 Drupalcamp Paris 2019 - L’expérience
développeur dans Drupal 8 : améliorons-la ! • Less frustration • Increased productivity • A better reputation • Attract more users -
Return on experience 14 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! -
Who am I? 15 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! • Thomas Calvet - fancyweb • 6 years experience in PHP • Long time Symfony user and enthusiast • New Drupal developer -
Drupalisnot readyfor developmentout of the box 16 Drupalcamp Paris 2019
- L’expérience développeur dans Drupal 8 : améliorons-la ! -
Missing concepts 17 Drupalcamp Paris 2019 - L’expérience développeur dans
Drupal 8 : améliorons-la ! • No « debug » mode • No « environment » -
Examples 18 Drupalcamp Paris 2019 - L’expérience développeur dans Drupal
8 : améliorons-la ! -
Display exceptions and errors 19 Drupalcamp Paris 2019 - L’expérience
développeur dans Drupal 8 : améliorons-la ! sites/default content -
Display exceptions and errors 20 Drupalcamp Paris 2019 - L’expérience
développeur dans Drupal 8 : améliorons-la ! Step 1 -
Display exceptions and errors 21 Drupalcamp Paris 2019 - L’expérience
développeur dans Drupal 8 : améliorons-la ! Step 2 -
Display exceptions and errors 22 Drupalcamp Paris 2019 - L’expérience
développeur dans Drupal 8 : améliorons-la ! Step 3 -
Display exceptions and errors 23 Drupalcamp Paris 2019 - L’expérience
développeur dans Drupal 8 : améliorons-la ! Step 4 -
Display exceptions and errors 24 Drupalcamp Paris 2019 - L’expérience
développeur dans Drupal 8 : améliorons-la ! • A basic and common need • Way too many steps for a new Drupal developer • It should be enabled from the start in local -
Drupal cache system 25 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! 13 tables of cache data -
Drupal cache system 26 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! Cache data content is unreadable -
Drupal cache system 27 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! Clearable caches with drush -
Drupal cache system 28 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! • Hard to master • Lots of terms : internal, dynamic, Twig, render, keys, tags, context, max age • Even way harder to understand for the front developers -
It leads to bad habits 29 Drupalcamp Paris 2019 -
L’expérience développeur dans Drupal 8 : améliorons-la ! • You must clear a cache but you don’t know which one • So you clear all cache • Precious seconds wasted everytime -
Are thereinitiatives? Yes! 30 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! -
From the community 31 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! • Drupal console commands • drush commands • Devel module -
From the core 32 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! • D8DX: Improving the D8 developer experience https://www.drupal.org/community-initiatives/drupal-core/d8dx • List DX issues • Provide a common vocabulary -
ekino/drupal-debug https://github.com/ekino/drupal-debug 34 Drupalcamp Paris 2019 - L’expérience développeur dans
Drupal 8 : améliorons-la ! • Open source third party library • Improve your DX during the development process • Help you develop better and faster • Reuse well known and well tested open source components -
Provide actions 35 Drupalcamp Paris 2019 - L’expérience développeur dans
Drupal 8 : améliorons-la ! • An action is a class that does something • Each action has an unique goal • 16 actions at the moment -
Drupaldevelopment configuration 36 Drupalcamp Paris 2019 - L’expérience développeur dans
Drupal 8 : améliorons-la ! -
Disable CSS & JS aggregations 37 Drupalcamp Paris 2019 -
L’expérience développeur dans Drupal 8 : améliorons-la ! Before After -
Disable CSS & JS aggregations 38 Drupalcamp Paris 2019 -
L’expérience développeur dans Drupal 8 : améliorons-la ! What it replaces -
Override Drupal configuration 39 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! • Global $config variable • Normally, you modify it in the settings.php file • The library just override everything after the settings initialization -
Disable Drupal caches 41 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! What it replaces -
Override Drupal settings 42 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! • Settings class singleton • Normally, you modify it in the settings.php file • The library just override everything after the settings initialization -
Twigdevelopment configuration 43 Drupalcamp Paris 2019 - L’expérience développeur dans
Drupal 8 : améliorons-la ! -
Enable Twig debug 44 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! Before After -
Enable Twig debug 45 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! What it replaces -
Override Twig configuration 46 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! • Twig configuration is defined by parameters • Override those parameters before the container compilation • Twig cache is also disabled with this way -
Display more information in a prettierway 47 Drupalcamp Paris 2019
- L’expérience développeur dans Drupal 8 : améliorons-la ! -
Display pretty exceptions 48 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! Before -
Display pretty exceptions 49 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! After -
Display pretty exceptions 50 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! • Use Symfony HttpKernel component ExceptionListener • Use Symfony Debug component ExceptionHandler • Available after the environment boot, so very early -
Enable Debug class loader 51 Drupalcamp Paris 2019 - L’expérience
développeur dans Drupal 8 : améliorons-la ! Provide better exceptions messages for case sensitive filesystems -
Enable Debug class loader 52 Drupalcamp Paris 2019 - L’expérience
développeur dans Drupal 8 : améliorons-la ! • Use the Symfony Debug component DebugClassLoader class • Wrap your autoloader (a Composer ClassLoader instance most likely) • Also does lightweight static analysis when a class is loaded -
Display dump location 53 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! Before -
Display dump location 54 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! After -
Display dump location 55 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! • Use the Symfony VarDumper component • Define a custom handler -
Enforcegood practices 56 Drupalcamp Paris 2019 - L’expérience développeur dans
Drupal 8 : améliorons-la ! -
Throw errors as exceptions 57 Drupalcamp Paris 2019 - L’expérience
développeur dans Drupal 8 : améliorons-la ! Code example -
Throw errors as exceptions 58 Drupalcamp Paris 2019 - L’expérience
développeur dans Drupal 8 : améliorons-la ! Before -
Throw errors as exceptions 59 Drupalcamp Paris 2019 - L’expérience
développeur dans Drupal 8 : améliorons-la ! After -
Throw errors as exceptions 60 Drupalcamp Paris 2019 - L’expérience
développeur dans Drupal 8 : améliorons-la ! • PHP errors must be handled • Use the Symfony Debug Component ErrorHandler class • Set a custom error handler that rethrow PHP errors as exceptions -
Enable Twig strict variables 61 Drupalcamp Paris 2019 - L’expérience
développeur dans Drupal 8 : améliorons-la ! Code example -
Enable Twig strict variables 62 Drupalcamp Paris 2019 - L’expérience
développeur dans Drupal 8 : améliorons-la ! Before -
Enable Twig strict variables 63 Drupalcamp Paris 2019 - L’expérience
développeur dans Drupal 8 : améliorons-la ! After -
Invalidatecaches automatically 64 Drupalcamp Paris 2019 - L’expérience développeur dans
Drupal 8 : améliorons-la ! -
Watch actions 65 Drupalcamp Paris 2019 - L’expérience développeur dans
Drupal 8 : améliorons-la ! • Detect files creation, alteration and deletion • Invalidate a cache • 3 actions at the moment -
Watch container definitions 66 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! Default watched files -
Watch modules hooks implementation 67 Drupalcamp Paris 2019 - L’expérience
développeur dans Drupal 8 : améliorons-la ! Default watched file -
Watch routing definitions 68 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! Default watched file -
Watch systems 69 Drupalcamp Paris 2019 - L’expérience développeur dans
Drupal 8 : améliorons-la ! • A resources freshness checker system • A file resource is tied to an extension • A file cache system • A file backend cache system -
How doesitwork? 70 Drupalcamp Paris 2019 - L’expérience développeur dans
Drupal 8 : améliorons-la ! -
It could not be a module 71 Drupalcamp Paris 2019
- L’expérience développeur dans Drupal 8 : améliorons-la ! • Modules are handled too late in the boot • Some actions would be impossible to implement • It would need to be enabled on first use • It would need to be managed to not be used on production -
Use another Kernel 72 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! Drupal front controller -
Use an alternative Kernel 73 Drupalcamp Paris 2019 - L’expérience
développeur dans Drupal 8 : améliorons-la ! • Extends the Drupal Kernel • Dispatch events • Alter the container definitions -
Substitutingthe original DrupalKernel 74 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! -
How does the substitution work? 75 Drupalcamp Paris 2019 -
L’expérience développeur dans Drupal 8 : améliorons-la ! • Create a copy of the DrupalKernel on the fly • Use another name • Replace paths references • Alias the DrupalKernel with our DebugKernel -
The substitution is great 76 Drupalcamp Paris 2019 - L’expérience
développeur dans Drupal 8 : améliorons-la ! • The library works out of the box • The Debug Kernel is used by any third party library that woud normally use the Drupal Kernel -
The substitution is bad 77 Drupalcamp Paris 2019 - L’expérience
développeur dans Drupal 8 : améliorons-la ! • Compatibility problems • Disable it to test a behavior with caches enabled • Disable it for all your tests -
Configuration 78 Drupalcamp Paris 2019 - L’expérience développeur dans Drupal
8 : améliorons-la ! -
Default configuration 79 Drupalcamp Paris 2019 - L’expérience développeur dans
Drupal 8 : améliorons-la ! • Some actions are configurable with options • Not mandatory because there are defaults values • Configuration is done in a YAML file • Some with environment variables -
Requirements 80 Drupalcamp Paris 2019 - L’expérience développeur dans Drupal
8 : améliorons-la ! -
Requirements 81 Drupalcamp Paris 2019 - L’expérience développeur dans Drupal
8 : améliorons-la ! • Composer • PHP >= 7.1 (last supported stable version) • Drupal >= 8.6 (latest minor version) -
What’snext? 82 Drupalcamp Paris 2019 - L’expérience développeur dans Drupal
8 : améliorons-la ! -
Improvements 83 Drupalcamp Paris 2019 - L’expérience développeur dans Drupal
8 : améliorons-la ! • On existing actions • Optional actions • Configuration by action -
More actions and features 84 Drupalcamp Paris 2019 - L’expérience
développeur dans Drupal 8 : améliorons-la ! • Watch themes hooks implementations • Watch libraries (JS & CSS files) • Support third parties actions -
The hidden goal 85 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! • A wake up call! • To have a debug mode in the Drupal core • To have more DX initiatives in the Drupal core -
Final thoughts 86 Drupalcamp Paris 2019 - L’expérience développeur dans
Drupal 8 : améliorons-la ! -
An enriching experience 87 Drupalcamp Paris 2019 - L’expérience développeur
dans Drupal 8 : améliorons-la ! • For me • For Drupal • For Symfony -
Is the community interested? 88 Drupalcamp Paris 2019 - L’expérience
développeur dans Drupal 8 : améliorons-la ! • Is it useful for a lot of developers? • Find first users and testers • Eventually find contributors -
https://github.com/ekino/ drupal-debug 90 Drupalcamp Paris 2019 - L’expérience développeur dans
Drupal 8 : améliorons-la !