Start of Main Content

This year I attended my first Drupalcon! And I gave a lightning talk, which was another first for me! I presented for 15 minutes about an Acquia Site Studio build with a custom search API React implementation. I’ll go over the details of my talk another time, but before then I wanted to share some valuable things that I learned at the conference. These insights will help you move your development process forward and improve it.

Along with a wonderful Driesnote, there were many sessions full of useful information. Some of them included updates to configuration validation, communication strategies, and the impacts of open-source development. And there was our own Kevin Quillen’s talk, which focused on a new module that leverages AI and ChatGPT in Drupal 10. Also, there was a talk about the updates coming in version 12 of Drush for Drupal. I plan to focus on this talk and how these changes will impact future Drush usage because I think they’re important to the Drupal community.

The Drush Talk

On the first day of DrupalCon (June 5th) I attended the “Drush 12 Modernized” talk, which was hosted by Moshe Weitzman (Tag1) and Greg Anderson (Pantheon). The focus of this update was to ensure forward compatibility with Drupal 10+, PHP 8.1+, and Symfony 6. Since they’re the developers/maintainers of Drush, this talk was a wonderful opportunity to get some valuable information about the upcoming release of version 12.

At Velir we’ve been looking forward to a version 12 release and have been watching the release candidates (as well as the dev version) for some time now. As an added surprise, at the end of the talk, the final release for Drush 12 was launched! So, this new version of Drush has been available since June 5th.

What is Drush?

Drush is a Drupal interface that allows you to run processes using the command line instead of using the Drupal admin panel or writing custom processes for routine developer tasks. It’s very helpful to someone who enjoys working more in the command line or needs to run actions through automation or cron jobs.

Drush Requirements

To use Drush 12 you’ll need to make sure you’re using Drupal version 10+ and running PHP 8.1+. It’s also necessary to install Drush 12 using Composer. This ensures that the Drush application can run on the installed Drupal site. View the install documentation.

Be aware that even though this is a requirement and Drush will only work for this website, it can still be used with external site setups using aliases. Read more information on the alias process.

Building Custom Commands

To build custom commands you can use the drush generate dcf command. This is the same as it was in previous versions, except now it follows an updated format utilized in Drupal Code Generator v3. See the generators source and compatibility. This will build you a skeleton for your own Drush command.

As far as making sure your new command will be found by Drupal, there are a couple of different ways it can be used. The first way is to allow the command to be discoverable via PSR4. Now that it is auto-loadable you can assign this command in a pre-defined location, but you will need to make sure it is still in the correct folder structure such as src/Drush/Commands.

The other option is that you can make this command specific to your custom module. You just need to ensure that it’s in the folder module/src/Drush/Commands. This will allow it to be discovered after your custom module is active and installed.

Learn more about the benefits of Drush version 12.

Our team of Drupal experts can show you helpful commands in the latest version of Drush and how your team can use them to gain efficiencies in your Drupal development process.

What’s New in Drush 12?

There are a handful of new or updated commands in Drush 12. These commands will allow you to either replace previous custom commands or shorten your work setup time for a new Drupal website. Here they are.

yaml

This command allows you to read, update, or remove settings within .yml files. This is a big deal because up until now you could not easily manipulate .yml files. There is also an option to validate those .yml files, which could come in very handy for pre-deployment or hotfix validations.

entity

This was available in previous versions of Drush, but the processes themselves have been drastically improved. The command allows you to delete or save specific entities. With this update, the process is faster and allows for a more verbose experience if needed.

archive

This is another command that was cleaned up during this update. It allows you to back up your code, files, and database into a single file. Once this is done, you could then import it onto another Drupal instance and have a duplicate site. I haven’t tested this to see how much better the performance is, but it's nice to have for those clients that may not have access to other means of site duplication.

maintenance

This command has been available since v11.5, but it was simplified. It allows you to get or set the maintenance mode of your Drupal site, or it can report back the current maintenance status. This is very nice for managing your site access without having to worry about handling it through the Drupal admin panel.

The final new thing I learned about Drush 12 was shell command completion. It allows you to install a script into bash, fish, or zsh to allow for auto-completion within the command line. This will be handy for those that live in the command line. View instructions on how to get started with the installation.

This is All Great, But What Now?

As Drush continues to improve, it only makes working in Drupal easier for developers. Taking some mundane processes out of the admin panel and into the command line not only makes us more efficient but also keeps these processes synonymous between all of us. There are already patches getting released that update the current commands to make them function better and faster in PHP 8.1+ and Symfony 6+, so we’re excited to see what comes next in the Drush landscape!

Want to know more about Drush and how it can help you streamline your Drupal development? Contact us.

Published:

Latest Ideas

Take advantage of our expertise with your next project.