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.
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
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
- Lando
ddev composer config minimum-stability --merge --json "dev"
lando 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
- Lando
ddev composer require octahedroid/drupal-decoupled-graphql-basic-recipe
lando 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
- Lando
ddev exec -d /var/www/html/web php core/scripts/drupal recipe ../recipes/drupal-decoupled-graphql-basic-recipe
cd web && \
lando php core/scripts/drupal recipe ../recipes/drupal-decoupled-graphql-basic-recipe && \
cd ..
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
- Lando
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
lando composer config allow-plugins.ewcomposer/unpack true
lando composer config repo.recipe-unpack vcs https://github.com/woredeyonas/Drupal-Recipe-Unpack.git
lando composer require ewcomposer/unpack:dev-master
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
- Lando
ddev composer unpack octahedroid/drupal-decoupled-graphql-basic-recipe
lando 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
- Lando
ddev composer install
lando composer install
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.
- drupal-decoupled-graphql-advanced-recipe: Advanced recipe, this is a turnkey and ready to use solution.
- drupal-decoupled-graphql-basic-recipe: Basic recipe, this is a starting point based on the standard installation profile.
Please review the README
files of each repository for more information about installation and usage.