Best Practices With Composable Drupal

September 13, 2023 | Chris Greatens
Best Practices With Composable Drupal

Many organizations depend on Drupal to build digital ecosystems. As a powerful content management system (CMS), it works well as one of the cornerstones of a composable architecture—but it can also function as its own standalone composable architecture. A composable approach has several benefits, including making it easier and more efficient to build out new channels (e.g., new websites or landing pages). It also empowers the business— especially the marketing team—to create and deliver content to customers where and when it is needed. This frees up developers to work on projects that deliver the most value. 

Here, we outline some of the best practices to build out a digital ecosystem using Drupal.

Tips to Build Reusable Front-End Components 

Using a tool like Drupal means that companies will benefit from the experiences and recommendations from the broader Drupal community, as ideas are shared and discussed widely. With our own clients and contributions to the Drupal community, as well as considering the enterprise tools available, we’ve identified a number of recurring practices that can help make this process easier.

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 core since Drupal 8, and the Drupal community continues to add features and refine the experience to enable ambitious site builders. 

Layout Builder allows developers to build components and templates that give marketers greater 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, which makes it even better. With Site Studio, marketers can not only build out new content using reusable components and templates, they can update styling to the components as well. Site Studio makes it efficient for developers by providing a user interface (UI) kit that includes components and helpers to get the build started. Acquia Site Studio makes building reusable components a breeze.

Create Efficient Development Processes with 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 ensure quality, and creating 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 doing so very easy. Once the CI/CD pipeline is built out, the process is automatically kicked off when a developer commits a change to the code base. If the process detects any issues, the developer gets immediate feedback and can fix those issues. All this automation makes the development process quicker so if there is a new feature or an enhancement to an existing feature that is needed, the development team can deliver it quickly. 

Use Composer to Manage Drupal and Dependencies

Another key component to an efficient development process for Drupal projects is using Composer to manage Drupal and all other dependencies, like libraries, modules, and themes and their dependencies. Using Composer makes it easy to ensure all the needed dependencies are installed and ensures that all developers are using the exact same version of all the libraries, modules, and themes. This helps prevent issues where it works in one developer’s environment, but not in another developer’s environment. 

Simplify the Development Process with Acquia Code Studio

Acquia has developed tools such as Acquia Code Studio that help developers create an efficient development process. Code Studio includes everything needed 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 the 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 in this sense means not only the code needed to implement business processes, but also any data mapping needed to 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. 

Whether you are implementing a traditional Drupal theme or using Drupal as a headless CMS, the business logic should be out of the theme layer. 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

Often developers will talk about future-proofing what they are building. However, the future is hard to predict. (Any developer that has been asked for an estimation knows this to be true.) Without being able to predict the future, we cannot future-proof our system. We can, however, future-prep our system. 

Isolating the business logic is a great example of future-prepping. By isolating the business logic, companies can minimize the disruption in the system as changes are inevitably needed. Marketing teams 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 CDP and PIM that can be easily plugged into your existing platform. In short, Acquia’s products make it easy to grow at your pace.

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 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 make the process of development reliable and efficient.