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
91 slides
-
DevelopereXperience 2 Drupal Dev Days Transylvania - Drupal Debug: improve
your developer experience -
Developer experience 3 Drupal Dev Days Transylvania - Drupal Debug:
improve your developer experience • 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 Drupal Dev Days
Transylvania - Drupal Debug: improve your developer experience • Several developer profiles • Site builder • Theme builder • Custom module maker -
So, whatisthe topic today? 5 Drupal Dev Days Transylvania -
Drupal Debug: improve your developer experience -
This talk is about 6 Drupal Dev Days Transylvania -
Drupal Debug: improve your developer experience • Your custom code • Daily development • Avoid repetitive tasks • Help new Drupal developers -
This talk is not about 7 Drupal Dev Days Transylvania
- Drupal Debug: improve your developer experience • Admin part • Core architecture / code • Documentation • Contribution -
Examplesof DX features 8 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience -
Provide shortcuts 9 Drupal Dev Days Transylvania - Drupal Debug:
improve your developer experience • Abstract implementations • Functions, methods, classes, traits • The goal is to hide a complexity -
Throw exceptions 10 Drupal Dev Days Transylvania - Drupal Debug:
improve your developer experience • Handle common users mistakes • Be defensive • Throw an exception • With an useful message -
Simple things 11 Drupal Dev Days Transylvania - Drupal Debug:
improve your developer experience • A small UI change • An up to date PHPDoc • Rename a test class • Etc. -
Whydoesitmatter? 12 Drupal Dev Days Transylvania - Drupal Debug: improve
your developer experience -
Why does it matter? 13 Drupal Dev Days Transylvania -
Drupal Debug: improve your developer experience • Less frustration • Increased productivity • A better reputation • Attract more users -
Return on experience 14 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience -
Who am I? 15 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience • Thomas Calvet - fancyweb • 6 years experience in PHP • Long time Symfony user and enthusiast • New Drupal developer -
Drupalisnot readyfor developmentout of the box 16 Drupal Dev Days
Transylvania - Drupal Debug: improve your developer experience -
Missing concepts 17 Drupal Dev Days Transylvania - Drupal Debug:
improve your developer experience • No « debug » mode • No « environment » management -
Examples 18 Drupal Dev Days Transylvania - Drupal Debug: improve
your developer experience -
Display exceptions and errors 19 Drupal Dev Days Transylvania -
Drupal Debug: improve your developer experience sites/default content -
Display exceptions and errors 20 Drupal Dev Days Transylvania -
Drupal Debug: improve your developer experience Step 1 -
Display exceptions and errors 21 Drupal Dev Days Transylvania -
Drupal Debug: improve your developer experience Step 2 -
Display exceptions and errors 22 Drupal Dev Days Transylvania -
Drupal Debug: improve your developer experience Step 3 -
Display exceptions and errors 23 Drupal Dev Days Transylvania -
Drupal Debug: improve your developer experience Step 4 -
Display exceptions and errors 24 Drupal Dev Days Transylvania -
Drupal Debug: improve your developer experience • 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 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience 13 tables of cache data -
Drupal cache system 26 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience Cache data content is unreadable -
Drupal cache system 27 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience Clearable caches with drush -
Drupal cache system 28 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience • 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 Drupal Dev Days Transylvania
- Drupal Debug: improve your developer experience • 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 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience -
From the community 31 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience • Drupal console commands • drush commands • Devel module -
From the core 32 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience • D8DX: Improving the D8 developer experience https://www.drupal.org/community-initiatives/drupal-core/d8dx • List DX issues • Provide a common vocabulary -
Proposingsomethingnew 33 Drupal Dev Days Transylvania - Drupal Debug: improve
your developer experience -
ekino/drupal-debug https://github.com/ekino/drupal-debug 34 Drupal Dev Days Transylvania - Drupal Debug:
improve your developer experience • 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 Drupal Dev Days Transylvania - Drupal Debug:
improve your developer experience • An action is a class that does something • Each action has an unique goal • 16 actions at the moment -
Drupaldevelopment configuration 36 Drupal Dev Days Transylvania - Drupal Debug:
improve your developer experience -
Disable CSS & JS aggregations 37 Drupal Dev Days Transylvania
- Drupal Debug: improve your developer experience Before After -
Disable CSS & JS aggregations 38 Drupal Dev Days Transylvania
- Drupal Debug: improve your developer experience What it replaces -
Override Drupal configuration 39 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience • Global $config variable • Normally, you modify it in the settings.php file • The library just overrides everything after the settings initialization -
DisableDrupalcaches 40 Drupal Dev Days Transylvania - Drupal Debug: improve
your developer experience -
Disable Drupal caches 41 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience What it replaces -
Override Drupal settings 42 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience • Settings class singleton • Normally, you modify it in the settings.php file • The library just overrides everything after the settings initialization -
Twigdevelopment configuration 43 Drupal Dev Days Transylvania - Drupal Debug:
improve your developer experience -
Enable Twig debug 44 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience Before After -
Enable Twig debug 45 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience What it replaces -
Override Twig configuration 46 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience • 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 Drupal Dev Days
Transylvania - Drupal Debug: improve your developer experience -
Display pretty exceptions 48 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience Before -
Display pretty exceptions 49 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience After -
Display pretty exceptions 50 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience • Use Symfony HttpKernel component ExceptionListener • Use Symfony Debug component ExceptionHandler • Available after the environment boot, so very early -
Enable Debug class loader 51 Drupal Dev Days Transylvania -
Drupal Debug: improve your developer experience Provide better exceptions messages for case sensitive filesystems -
Enable Debug class loader 52 Drupal Dev Days Transylvania -
Drupal Debug: improve your developer experience • 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 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience Before -
Display dump location 54 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience After -
Display dump location 55 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience • Use the Symfony VarDumper component • Define a custom handler -
Enforcegood practices 56 Drupal Dev Days Transylvania - Drupal Debug:
improve your developer experience -
Throw errors as exceptions 57 Drupal Dev Days Transylvania -
Drupal Debug: improve your developer experience Code example -
Throw errors as exceptions 58 Drupal Dev Days Transylvania -
Drupal Debug: improve your developer experience Before -
Throw errors as exceptions 59 Drupal Dev Days Transylvania -
Drupal Debug: improve your developer experience After -
Throw errors as exceptions 60 Drupal Dev Days Transylvania -
Drupal Debug: improve your developer experience • 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 Drupal Dev Days Transylvania -
Drupal Debug: improve your developer experience Code example -
Enable Twig strict variables 62 Drupal Dev Days Transylvania -
Drupal Debug: improve your developer experience Before -
Enable Twig strict variables 63 Drupal Dev Days Transylvania -
Drupal Debug: improve your developer experience After -
Invalidatecaches automatically 64 Drupal Dev Days Transylvania - Drupal Debug:
improve your developer experience -
Watch actions 65 Drupal Dev Days Transylvania - Drupal Debug:
improve your developer experience • Detect files creation, alteration and deletion • Invalidate a cache • 3 actions at the moment -
Watch container definitions 66 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience Default watched files -
Watch modules hooks implementation 67 Drupal Dev Days Transylvania -
Drupal Debug: improve your developer experience Default watched file -
Watch routing definitions 68 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience Default watched file -
Watch systems 69 Drupal Dev Days Transylvania - Drupal Debug:
improve your developer experience • A file resource is tied to an extension (a module or a theme) • A resources freshness checker system • A file cache system • A file backend cache system -
How doesitwork? 70 Drupal Dev Days Transylvania - Drupal Debug:
improve your developer experience -
It could not be a module 71 Drupal Dev Days
Transylvania - Drupal Debug: improve your developer experience • 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 an alternative Kernel 72 Drupal Dev Days Transylvania -
Drupal Debug: improve your developer experience Drupal front controller -
Use an alternative Kernel 73 Drupal Dev Days Transylvania -
Drupal Debug: improve your developer experience • Extend the Drupal Kernel • Dispatch events • Alter the container definitions -
Substitutingthe original DrupalKernel 74 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience -
How does the substitution work? 75 Drupal Dev Days Transylvania
- Drupal Debug: improve your developer experience • Create a copy of the DrupalKernel on the fly • Use another name • Replace __DIR__ references • Alias the DrupalKernel with our DebugKernel -
The substitution is great 76 Drupal Dev Days Transylvania -
Drupal Debug: improve your developer experience • 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 Drupal Dev Days Transylvania -
Drupal Debug: improve your developer experience • Compatibility problems • Disable it to test a behavior with caches enabled • Disable it for all your tests -
Configuration 78 Drupal Dev Days Transylvania - Drupal Debug: improve
your developer experience -
Default configuration 79 Drupal Dev Days Transylvania - Drupal Debug:
improve your developer experience • 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 Drupal Dev Days Transylvania - Drupal Debug: improve
your developer experience -
Requirements 81 Drupal Dev Days Transylvania - Drupal Debug: improve
your developer experience • Composer • PHP >= 7.1 (last supported stable version) • Drupal >= 8.6 -
What’snext? 82 Drupal Dev Days Transylvania - Drupal Debug: improve
your developer experience -
Improvements 83 Drupal Dev Days Transylvania - Drupal Debug: improve
your developer experience • On existing actions • Optional actions (opened PR) • Configuration by action (opened PR) -
More actions and features 84 Drupal Dev Days Transylvania -
Drupal Debug: improve your developer experience • Watch themes hooks implementations • Watch libraries (JS & CSS files) • Support third parties actions (opened PR) -
The hidden goal 85 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience • 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 Drupal Dev Days Transylvania - Drupal Debug:
improve your developer experience -
An enriching experience 87 Drupal Dev Days Transylvania - Drupal
Debug: improve your developer experience • For me • For Drupal • For Symfony -
Is the community interested? 88 Drupal Dev Days Transylvania -
Drupal Debug: improve your developer experience • Is it useful for a lot of developers? • Find first users and testers • Eventually find contributors -
https://github.com/ekino/ drupal-debug 90 Drupal Dev Days Transylvania - Drupal Debug:
improve your developer experience -
WHAT DID YOU THINK? Locate this session at the Drupal
Developer Days Transylvania 2019 website: https://cluj2019.drupaldays.org/schedule Take the survey! https://www.surveymonkey.com/r/drupaltransylvania THANK YOU!