Skip to main content

Extend

Extending and Configuring Drupal for web applications can be challenging at first and requires many adjustments. However, recipes simplify the process by offering a set of ready-to-install configurations to be applied to your installation.

Making Drupal ready to use as a headless CMS is not the exception, and for this reason, recipes are the best way to help you start your next Drupal decoupled implementation.

warning

Drupal recipes had been added to the core as experimental in 10.3 and above. The following instructions will be based on this assumption.

Preparing Drupal

This guide shows how to install a Drupal decoupled recipe according to the recipes Initiative

info

We will follow as guide a setup using drupal/recommended-project as a template for illustration purposes.

Configure composer.json

Some modules of our recipes are still in active development; for this reason, changing the minimum-stability of composer is necessary to download all dependencies.

ddev composer config minimum-stability --merge --json "dev"

Ignoring downloaded recipes

If you start a git repository of your project, you will find that the recipe is downloaded, and since this is managed by composer, you'll want to exclude the /recipes path.

echo "/recipes" >> .gitignore

Require the recipe

ddev composer require octahedroid/drupal-decoupled-graphql-basic-recipe

Applying the recipe

Recipes are applied using core's PHP Drupal script. In your CLI, cd into your webroot, and run the following command:

ddev exec -d /var/www/html/web php core/scripts/drupal recipe ../recipes/drupal-decoupled-graphql-basic-recipe

Unpacking the recipe and making it part of your installation

This is an optional step. However, these recipes are intended to be a starting point for your Drupal project, and we strongly recommend unpacking the recipe and, with that, integrating the dependencies into your main project's composer.json file.

ddev composer config allow-plugins.ewcomposer/unpack true
ddev composer config repo.recipe-unpack vcs https://github.com/woredeyonas/Drupal-Recipe-Unpack.git
ddev composer require ewcomposer/unpack:dev-master
tip

If you execute the commands above successfully, feel free to continue to the unpack step

The https://github.com/woredeyonas/Drupal-Recipe-Unpack composer plugin can be run after you apply a recipe.

The plugin is not on Packagist, so you must first install the repository in your site, adding the following lines to your site's composer.json file at the repositories section.

{
"type": "vcs",
"url": "https://github.com/woredeyonas/Drupal-Recipe-Unpack.git"
}

Require the package.

ddev composer require ewcomposer/unpack:dev-master

When using Composer 2.2 or higher, Composer will ask for your permission to allow this plugin to execute code.

Add the following lines to your site's composer.json file at the config > allow-plugins section.

{
"config": {
"allow-plugins": {
"ewcomposer/unpack": true
}
}
}

Unpack the recipe

Unpack the recipe with the following command.

ddev composer unpack octahedroid/drupal-decoupled-graphql-basic-recipe

After this, the dependencies have been added to your main composer.json, then we just need a cleanup of the recipe and remove the downloaded files

ddev composer install
info

The recipe is now part of your project, and you can continue setting up your front end application.

Drupal Decoupled recipes

Here is a set of recipes according to the recipes initiative, designed to configure Drupal as a headless CMS ready to be integrated with a Frontend application.

note

Please review the README files of each repository for more information about installation and usage.