3 min - Drupal

Recipes: The New Concept of Drupal 10

Published on Apr 3, 2024

Recipes: The New Concept of Drupal 10

Recipes in Drupal are predefined configurations that allow for quick and easy installation and setup of websites. By using recipes in Drupal, users can save time and effort in the initial configuration of their site, as they have a solid and optimized base to meet their needs. Today, we invite you to delve deeper and learn about this new feature in Drupal.

Recipes are a new concept in Drupal 10, designed to replace the previous approach of distribution or installation profile for websites. Their goal is to decouple an installation from its base to make them more manageable and tailored to the specific needs of the site. They were added to the core in Drupal 10.3 as experimental features.

Core recipes can be found in /core/recipes. Custom and contributed recipes are stored in /recipes.

Main Features of Recipes

The main features of recipes are:

• Act as scripts: They leave no trace and do not remain active during the site's lifetime, with no impact on performance and are reversible.

• Code installation: They can install modules and themes through dependencies but do not contain PHP files.

• Configuration modification: They can make changes to existing configurations via configuration actions without the need for programming.

Structure of a Drupal Recipe

In the folder containing a recipe, there will be at least a recipe.yml file with this structure:

Visible name of the recipe, as it will be listed.

name: 'Example recipe'

Optional description of the functionality it provides.

description: "An example Drupal recipe."

The type is similar to the package in modules, grouping recipes by usefulness criteria.The 'Content type' means the recipe will be listed as an option in the installer.

type: 'Content type'
recipes:

If the recipe depends on others, they will be listed here. All will be applied before it.

editorial_ui_for_publishers
another_recipe

install:

General dependencies (modules or themes) of the recipe.

easy_breadcrumb
node
text

config:

The recipe can control which configuration entities to install or not from those provided by the listed modules in its dependencies.These examples are hypothetical.

import:
easy_breadcrumb:
   - views.view.easy_breadcrumbs
node:
   - node.type.article
text: *

Actions on existing configuration. The name of the configuration to handle is declared, along with the specific action to perform (done by a plugin) and possible arguments.In the example, the user role 'Editor' will be created if it does not exist and then granted several permissions to work on the Article content type.

actions:
user.role.editor:
      ensure_exists:
        label: 'Editor'
      grantPermissions:
     - 'delete any article content'
     - 'edit any article content'

If a recipe needs to install new configuration, it is stored in a folder called "config." Each configuration entry is saved in a YAML (.yml) file whose name matches the defining element. All configuration provided by a recipe is installed unconditionally, so there are no subfolders like "config/install" or "config/optional."

Similarly, recipes incorporate a new API that simplifies modifying existing configuration through a declarative syntax. This API is independent of recipes and can be used by other modules to make configuration changes without programming.

The recipe development team encourages its use in development environments due to its low-risk nature. Since no significant changes in the already implemented structure are expected, it is unlikely that current recipes will require review.

To use recipes, extensive patches are supplied for its application in maintained versions of Drupal 10, minimizing conflicts with other patches. Additionally, a set of Drupal recipes is available for exploration and contribution.

Applying Recipes

Recipes are applied using the Drupal core PHP script. Navigate to your webroot and run:

php core/scripts/drupal recipe recipes/contrib/[recipe-name]

Although there is no specific date for the stable release of Drupal recipes, a team is actively working towards their medium-term implementation. They are likely to be integrated into a minor update of Drupal 10 or, at most, with the arrival of Drupal 11. This involves infrastructure adjustments, including the creation of a new extension type and its corresponding searcher on drupal.org.

Recipes are still in development and have certain limitations. Currently, they lack a system to manage updates once applied, making it difficult to establish a clear lifecycle. It is recommended to apply them only once and handle any subsequent changes differently.

Initially known as "starter templates," their main purpose is to provide a starting point for new projects. They are expected to replace Drupal installation profiles, such as Standard or Umami, representing an evolution of these. The best way to leverage this Drupal capability will depend on user experience.

We hope you find this new Drupal proposal valuable. If you want to deepen your knowledge of this powerful content management platform, we invite you to contact our team of experts at DigitalProjex. Our professionals will be happy to offer personalized consulting and guide you through the next steps to successfully integrate Drupal into your digital ecosystem. Feel free to schedule a meeting to discuss how Drupal can transform and enhance your online presence.

Share This Post

Need consulting services to create a recipe for your company?

Contact Us
Blue chart
Read All Posts