Best Practices with Composable Drupal
- 9 minute read
-
Drupal is a unique CMS that works well as one of the cornerstones of a composable architecture, but can also work like a composable architecture as well. Check out this article for a refresher on composable architectures and how Drupal can be used in a composable way. Drupal is a very powerful CMS, so many organizations choose to build their digital ecosystem using Drupal. If you decide to build out your digital ecosystem using Drupal, what are some of the best practices you should keep in mind?
Key benefits of a composable approach
Before diving into the best practices, let’s take a step back and review some of the key benefits of using a composable approach. Using a composable approach is better because it's easier and more efficient to add new channels (e.g., websites or landing pages). Another benefit is that the business can create and deliver content to customers where and when needed. This allows developers to work on projects that deliver the most value. To reap the benefits of a composable approach, there are a few things to keep in mind.
Tips for building reusable front-end components
Use Layout Builder to create reusable components
To build new channels efficiently, composable approaches seek to move building pages and channels out of the developers’ hands and into the marketers’ hands. A great way to do this is to build flexible, reusable front-end components. Drupal is well-equipped in this area. Layout Builder has been part of Drupal since Drupal 8. The Drupal community adds features and improves the experience to help ambitious site builders.. Layout Builder allows developers to build components and templates that give marketers great flexibility to build pages without the need for developer intervention. If a new landing page is needed, a content editor can quickly assemble the page from the reusable components and get it published quickly.
Provide an enterprise-grade UX with Acquia Site Studio
While Layout Builder is a great choice for building out reusable components, Acquia Site Studio provides an enterprise-grade user experience making it even better. With Site Studio, marketers can build content using reusable components and templates. They can also update the styling to the components. Site Studio makes it efficient for developers by providing a UI kit that includes components and helpers to get the build started. Acquia Site Studio makes building reusable components a breeze. If you’re interested in a deep dive into Site Studio vs Layout Builder, check this article out.
Create efficient development processes with continous integration / continuous deployment (CI/CD)
Building reusable components is an important aspect of a composable approach, but it is also important to have an efficient development process. A key component to having an efficient development process is creating a continuous integration/continuous delivery (CI/CD) pipeline. CI/CD pipelines make the development process efficient by automatically enforcing coding standards, testing the new code to guarantee quality, and creating the deployment artifacts so the code is always ready to be deployed. It has never been easier to create a CI/CD pipeline. All the major cloud-based source code version control providers offer tools to make building out the CI/CD pipeline very easy. Once the CI/CD pipeline is built out, when a developer commits a change to the code base, the process is automatically kicked off. If the process detects any issues, the developer gets immediate feedback and can fix those issues. Automation makes development quicker, so the team can deliver new features or improvements quickly.
Use Composer to manage drupal and dependencies
A good development process for Drupal projects is to use Composer to manage Drupal and all dependencies, like libraries, modules, and themes and their dependencies. Using Composer makes it easy to make sure all the needed dependencies are installed. Using Composer means everyone is using the same versions of libraries, modules, and themes, which prevents issues where it works in one developer’s environment, but not another developer’s environment.. Check out this article to learn how to upgrade to Drupal 10 (and beyond) with Composer.
Simplify the development process with Acquia Code Studio
Acquia has done some great work and developed some amazing tools that help developers create an efficient development process. Acquia Code Studio is a great example of this. Code Studio includes everything you need to have an efficient development process, from a zero-configuration CI/CD pipeline to automatically created feature branches to easy to create merge requests and more. In partnership with GitLab, Code Studio helps keep development tasks on target from feature request through production deployment. Acquia has done all the heavy lifting to build out a solid, efficient development process so you don’t need to.
Isolate your business logic
Another idea to keep in mind when using Drupal as a composable solution is that business logic should be isolated as much as possible. Business logic here means not only the code needed to implement your business processes, but also any data mapping you need as you integrate with other platforms. In a truly composable architecture, business logic would be built in the orchestration layer to keep the ecosystem front-end and back-end agnostic. With composable Drupal, Drupal acts as the orchestration layer, but that does not mean the business logic should go just anywhere.
The business logic should be out of the theme layer. It does not matter if you are implementing a traditional Drupal theme or using Drupal as a headless CMS. With a traditional Drupal theme, a good indication that you kept business logic out of the theme is if you can create a drop-in replacement for your theme. Whether you use a traditional Drupal theme or a headless implementation, the code should be narrowly focused on presentation.
Any business logic that is needed should be isolated to and grouped in custom modules. The more centralized the business logic is kept, the easier it will be to update or replace various parts of the system, like platform integrations, in the future.
Future-prep your system
The future will be here before you know it. Often developers will talk about future-proofing what they are building. But, the future is hard to predict. (Any developer that's been asked for an estimation knows this fact very well.) Without being able to predict the future, we cannot future-proof our system. We can, however, future-prep our system. Isolating business logic is a great example of this. By isolating the business logic, we can minimize disruption in the system as we inevitably need to make changes. Today, your marketing team may not have a need for an email marketing system, but that could easily change in the future. Building a system that can efficiently adapt to ever-changing business needs can give you an edge.
One of the attributes that I like about the Acquia Platform is that it is both built to be open, yet is also well-integrated. Because of the open nature of both Drupal and Acquia, you can build a best-of-breed system. And, if you already have a platform that is working well, it can easily be integrated into a Drupal-based solution built on Acquia. But, if as your needs grow, you find yourself needing to do more with customer data or need additional help managing your digital assets, Acquia has products like Acquia Customer Data Platform (Acquia CDP) and Acquia Product Information Management (Acquia PIM) that can be easily plugged into your existing platform. In short, Acquia’s products make it easy to grow at your pace. Check out this article to learn more about how composable is powering transformative digital experiences!
Empowering organizational agility through composable architecture with Drupal
A composable architecture provides organizations with the agility to react to their ever-changing business challenges. Using Drupal as a composable platform can help you achieve that agility. The key to achieving that agility is to put the power to freely create new content and channels in the hands of marketers so that developers can focus on building more tools that deliver value and to make the process of development reliable and efficient. The techniques discussed in this article are a good way to achieve both goals.