Marginal Gains & Technology Tips
Sir David Brailsford, a world-renowned cycling coach, is well known for his concept of “Marginal Gains." His idea was that if you could improve by just 1% each day or even each week, that you could produce a dramatic increase in results overall and/or by the end of the year.
He employed this strategy with Team Sky, the British cycling team, which then went on to produce 5 Tour de France wins over 7 years. This would do things like bringing their own mattresses to each new hotel, so the riders would sleep on a consistent surface, the same look/feel/smell every night. This resulted in improved sleep by about 6%.
They would do similar things with materials, weights, training patterns, etc. Each item brought a slight gain of 0.5 - 1%.
So what does the concept of marginal gains have to do with your work in technology?
We first have to ask ourselves if the same concepts can be applied to what we do. To web development and design. If we can make small, incremental, improvements each day…then we can potentially get 37x better and faster over the course of a year. Are you up for the challenge?
To help make these marginal gains, this blog will be a resource that shares small tips, shortcuts, insights, tools, etc. every week.
Please stay tuned for trusted tech tips from OPIN's Director of Technology.
Drupal Console & Generate:Module
November 3, 2020
From the ground up, it has been built to utilize the same modern PHP practices which were introduced in Drupal 8. Drupal Console started as a scaffolding tool but evolved into a full CLI with the help of multiple contributors.
The Drupal Console makes use of the Symfony Console and other third-party components which allows you to automatically generate most of the code needed for a Drupal 8/9 module. In addition, Drupal Console helps you interact with your Drupal installation.
The command that I am sharing today is one of my favourites: “generate:module”. This command creates the scaffolding needed for custom modules and allows you to start off with all of the files, basic details, and templates that you need for any custom module development. Simply run the command, with some options, and follow the prompts to create your starting point and scaffolding.
Generate a module specifying the module name, machine name, the path, its description, Drupal core and the package name. In this example, the composer file, the unit test and twig template are generated too.
Stay tuned, for another great Drupal Console command!
Drupal Console & Create:[content]
November 10, 2020
Until now, the Devel Generate module has been used to add dummy content to Drupal but there is a better way.
The following commands, that come with Drupal Console, allows you to add various pieces of content to your system, for testing.
Provide the content type name.
Provide the limit of publications, the limit of title words, time range and language.
Each create:[content] command has various options that you can use and include. You can check out a full list here: https://drupalconsole.com/docs/en/commands/
Stay tuned for next week's tech tip!
Drupal Console & Debug:[xyz]
One of the pain points of Drupal comes from having to debug anything from contributed modules to your own custom modules, and even core issues that may come up. Although we have many tools such as xdebug available to us, sometimes more is needed.
This is where Drupal Console’s debug:[xyz] command helps out!
There are over 35 debug commands that you can use to help configure Drupal, troubleshoot Drupal, or even just decide what to do next. Some example commands are as follows:
This command lists all modules in your system that are implementing cron. It is very useful to debug any cron issues and to see if there are any conflicts.
This command displays the current migrations available for the application, along with their details. Migrations are hard, especially if we are inheriting them from someone else. This command helps you get organized.
This command displays current routes for the application and can also display information for a particular route. Let’s face it, we have all had router issues with our custom modules. This is very useful to help you quickly determine if your routes are properly registered.
This command displays the current updates available from the composer file. This is useful for when you recognize there may be a bug with a module and you are not sure if there are updates available. A simple command run will help you determine what to do next.
There are many more examples that you can utilize and review. To see a complete list, check out the documentation at https://drupalconsole.com/docs/en/commands/