Three Step Functional Testing With Lando and Drupal
This article touches on a form of testing you can submit to the Drupal community, which is functional testing....
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!
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.
create:comments
Create dummy comments for your Drupal 8 application.
create:nodes
Create dummy nodes for your Drupal 8 application.
create:roles
Create dummy roles for your Drupal 8 application.
create:terms
Create dummy terms for your Drupal 8 application.
create:users
Create dummy users for your Drupal 8 application.
create:vocabularies
Create dummy vocabularies for your Drupal 8 application.
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!
November 19
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/
Happy dubugging!!!
Drupal Console & Database:[xyz]
Dec 3 2020,
Closing out on our mini Drupal Console series, I wanted to share one more command. The database:[xyz] command.
I wanted to share the following commands that should help you day-to-day when the need arises.
Add a database to settings.php
Launch a DB client if it's available
Shows DB connection
Drop all tables in a given database.
Dump structure and contents of a database
Remove events from DBLog table, filters are available
Poll the watchdog and print new log entries every x seconds
Executes a SQL statement directly as an argument
Restore the structure and contents of a database.
Although the use of the database:[xyz] commands are meant to be used by advanced users, it is my hope that it can help you troubleshoot anything!
Thanks for reviewing my mini-series on Drupal Console! Review the Drupal Console website for more details and even more available commands.
Performance and Render Blocking
Dec 10, 2020
Render means loading, so if something is render-blocking, it means that it is keeping the page from loading as quickly as it could.
Google recommends to remove or defer and CSS and/or Javascript that interferes with loading the items that appear above the fold of your webpages.
Above the fold means what a user sees initially on their screen. That screen might be a phone, iPad, desktop or whatever the user is using to see your webpage.
In the case of the CSS on the OPIN website, which uses Vue.js and Gridsome to generate a static site, I used a tool called Critical. Critical extracts & inlines critical-path (above-the-fold) CSS from HTML.
When it comes to Drupal, this is harder to do because of the nature of how Drupal renders content dynamically with everything essentially running through index.php. Although this is harder to do, some aspects are possible with the Advanced CSS/JS Aggregation module. AdvAgg allows you to improve the front-end performance of your site.
Via a modifier sub-module, as it related to Render Blocking, AdvAgg helps with the following:
Force preprocessing for all CSS/JS
Move JS to footer
Add defer tag to all JS (Fix render-blocking JS)
Inline all CSS/JS for given paths
Remove unused JavaScript tags if possible
Use JS to load CSS asynchronously (Fix render-blocking CSS)
If you have not checked out the Advanced CSS/JS Aggregation module, I encourage you to do so!
Steve Lavigne
President
Steve is a passionate storyteller who thrives on challenging the status quo. He is an avid researcher with a keen analytical mind able to strategize on technology, sales and marketing decisions by analyzing data and behaviours across various industries and technologies.
Three Step Functional Testing With Lando and Drupal
This article touches on a form of testing you can submit to the Drupal community, which is functional testing....
135 Laurier Ave. West, Suite 100
Ottawa, ON K1P 5J2
TEL: 1 (877) 257-6746
153 Regent Street
Saratoga Springs, NY 12866
TEL: 1 (877) 257-6746