SlideShare a Scribd company logo
Improving your Drupal 8
Development Workflow
by Jesus Manuel Olivas / WeKnow
Who I am?
Jesus Manuel Olivas
jmolivas@weknowinc.com
jmolivas
jmolivas
http://drupal.org/u/jmolivas
http://jmolivas.weknowinc.com
WeGive
2,572,697
WeAre
WeKnow
Local environment
Local environment.
Isolate local machine from project dependencies.
Easy and simple to start and continue working on existing projects.
Facilitate on boarding and adding new team members.
Project scope configurations.
Shareable with the team using a code repository via git.
Mimic production environment and other temporary stages.
Local environment.
●OS Native, LAMP, Dev Desktop
●XAMPP => https://www.apachefriends.org
●MAMP => https://www.mamp.info/en/
●WAMP => http://www.wampserver.com/en/
●Vagrant => https://www.vagrantup.com/
●Docker => https://www.docker.com/
Vagrant | Docker
Local environment.
DrupalVM => https://www.drupalvm.com/
Docksal => https://docksal.io/
DDEV => https://github.com/drud/ddev
Lando => https://docs.devwithlando.io/
Outrigger => http://outrigger.sh/
Docker4Drupal => https://github.com/wodby/docker4drupal
Ahoy
Ahoy
Ahoy is command line tool that gives each of
your projects their own CLI app with with zero
code and dependencies.
http://www.ahoycli.com
.ahoy.yml
ahoyapi: v2
commands:
up:
cmd: docker-compose up -d "$@"
usage: Create and start containers.
down:
cmd: docker-compose down "$@"
usage: Stop and remove containers, networks, images, and volumes.
composer:
cmd: docker-compose exec --user=wodby php composer "$@"
usage: Run Composer commands in the php service container.
drupal:
cmd: docker-compose exec --user=wodby php vendor/bin/drupal "$@"
usage: Run Drupal Console commands in the php service container.
Download and Install
Drupal 8
Download Drupal (Composer)
● https://github.com/weknowinc/drupal-project (drupal.dev)
●# Includes configurations for Docker and DrupalConsole.
●composer create-project weknowinc/drupal-project /path/to/drupal
# Clone project using git
git clone git@github.com:weknowinc/drupal-project.git
Manage environment variables (.env.dist => .env)
# Copy env file
cp .env.dist .env
# Customize values

vim .env
What if this is not a new project? | How to automate this?
# Create site alias, .env, and docker-compose.yml files.
drupal dockerize (Available on 1.9.0 ETA TBD)
# This will run
drupal generate:site:alias
drupal dotenv:init
drupal docker:init
Environment variables (.env)
ENVIRONMENT=develop
DATABASE_NAME=drupal
DATABASE_USER=drupal
DATABASE_PASSWORD=drupal
DATABASE_HOST=mariadb
DATABASE_PORT=3306
HOST_NAME=drupal.develop
HOST_PORT=80
DRUPAL_ROOT=/var/www/html
SERVER_ROOT=/var/www/html/web
Ignore configuration files (.gitignore)
# External dependencies
vendor
# Drupal dependencies
web/core
web/modules/contrib
web/themes/contrib
web/profiles/contrib
web/libraries/contrib
# Files

web/sites/*/files
# env file
.env
# DB backups
mariadb-init
The new directory structure
drupal.develop/ web/
├── LICENSE ├── autoload.php
├── README.md ├── core
├── composer.json ├── index.php
├── composer.lock ├── modules
├── scripts ├── profiles
├── vendor ├── sites
└── web └── themes
Interact with containers
# Start containers
ahoy up
# Stop containers
ahoy down
# Show logs
ahoy logs <SERVICE_NAME>
# Stop containers destroy data
ahoy destroy
docker-compose.yml | overview
version: "2.x"
services:
mariadb:
php:
nginx:
mailhog:
traefik:
volumes:
mysqldata:
driver: "local"
Using Composer to
manage project
dependencies
Composer
● https://getcomposer.org/
Improving your Drupal 8 development workflow DrupalCampLA
Using composer within the container
Drupal 8 really takes a lot of advantages of using composer,
you can install/uninstall dependencies and apply patches.
Although it’s a good practice when using Docker, to run this
commands inside your container because if you have a PHP
version on your local machine, you could install dependencies
that are not suitable for your container instance.
Manage dependencies
ahoy composer install
ahoy composer update
ahoy composer require drupal/admin_toolbar
ahoy composer update drupal/admin_toolbar
ahoy composer update drupal/admin_toolbar --with-dependencies
ahoy composer remove drupal/admin_toolbar
Composer commands
ahoy composer why drupal/admin_toolbar
ahoy composer show [-o] [drupal/admin_toolbar]
ahoy composer check-platform-reqs
ahoy composer diagnose
How composer know about Drupal dependencies
"repositories": [
{
"type": "composer",
"url": "https://packages.drupal.org/8"
}
],
How composer know where to download dependencies
"extra": {
"installer-paths": {
"docroot/core": [
"type:drupal-core"
],
"docroot/modules/contrib/{$name}": [
"type:drupal-module"
],
"docroot/theme/contrib/{$name}": [
“type:drupal-theme"
]
}
}
Apply patches (composer.json)
"extra": {
"patches": {
"drupal/admin_toolbar": {
"Patch description": “URL/local path to patch"
}
}
}
● https://github.com/cweagans/composer-patches
Composer configuration
"minimum-stability": "dev",
"prefer-stable": true,
"config": {
"platform": {
"php": "7.0",
"sort-packages": true
}
}
Managing external
libraries and dependencies
Register a drupal-library (composer.json)
"repositories": [
{
"type": "package",
"package": {
"name": "ckeditor/codesnippet",
"description": "This plugin …",
"type": "drupal-library",
"homepage": "https://ckeditor.com/cke4/addon/codesnippet",
"version": “4.7.3”,
"dist": {
"type": "zip",
"url": "https://download.ckeditor.com/codesnippet/releases/codesnippet_4.7.3.zip",
"reference": "master"
}
}
}
],
Download a drupal-library (composer)
composer require ckeditor/codesnippet
# composer.json
"extra": {
"installer-paths": {
"web/libraries/{$name}": [
“type:drupal-library"
],
}
}
Drupal Console
● https://drupalconsole.com
Drupal Console Launcher
https://docs.drupalconsole.com/en/getting/launcher.html
curl https://drupalconsole.com/installer -L -o drupal.phar
mv drupal.phar /usr/local/bin/drupal
chmod +x /usr/local/bin/drupal
Why do I need the Launcher?
This is a global executable that enables you to run the command, drupal, from any
directory within your site's project. Without it you will be inconvenienced by having to
run the command only from your drupal root directory.
For example, if you have Drupal root in a /web directory, and a composer.json and your
vendor directory in the directory above that, you will be able to run the drupal command
from the same directory as the composer.json file. Even better, you can run it from any
subdirectory under that as many levels deep as you would like to go.
https://docs.drupalconsole.com/en/getting/project.html
Drupal Console per-site installation
composer require drupal/console:~1.0 
--prefer-dist 
--optimize-autoloader
●https://docs.drupalconsole.com/en/getting/composer.html
Site alias
● https://docs.drupalconsole.com/en/alias/using-site-alias.html
Drupal Console allows you to run commands from your local server but being
able to execute those commands on a local, remote (VPS, PaaS) or virtual (VM,
Docker) Drupal installation using site aliases.
A site alias file use the YAML format to provide a collection of predefined
options. Once an alias is defined you can call them using a short name.
Site alias console/sites/drupal.yml (container | docker4drupal)
develop:
root: /var/www/html
extra-options: docker-compose exec --user=82 php
type: container
● https://docs.drupalconsole.com/en/alias/connecting-to-a-virtual-environment.html
Site alias console/sites/drupal.yml (ssh | drupalvm)
drupalvm:
root: /var/www/drupalvm/drupal
host: 192.168.88.88
user: vagrant
extra-options: '-o PasswordAuthentication=no -i ~/.vagrant.d/insecure_private_key'
type: ssh
● https://docs.drupalconsole.com/en/alias/connecting-to-a-virtual-environment.html
Execute Drupal Console using site alias
# Using the --target option

drupal --target=drupal.develop cr all
# Using the legacy @ identifier
drupal @drupal.develop cr all
Configuration Management
Managing configuration changes through the CLI.
Install Drupal and import a previously exported
configuration.
Override configuration per environment
Content synchronization.
Managing configuration
changes through the CLI.
Configuration Management
In Drupal, configuration is the collection of admin settings
that determine how the site functions, as opposed to the
content of the site.
Configuration will typically include things such as the site
name, the content types and fields, taxonomy vocabularies,
views and so on.
Configuration system
The Drupal configuration system handles configuration in a
unified manner.
By default, Drupal stores configuration data in the
database, but it can be exported to YAML files, allowing the
configuration to be managed by version control.
Configuration Management
Configuration is a mapping of keys and values.
Stored on the Database by default.
Exported as YAML for synchronization between environments.
Once a module is installed the configuration provided by the
module is owned by the site not the by the module anymore.
Exporting Configuration
drupal config:export
drupal config:export [--directory] [--tar]
drupal config:export:single [--directory] [--module]
drupal config:export:content:type
drupal config:export:view
Importing Configuration
drupal config:import
drupal config:import [--file] [--directory]
drupal config:import:single [--directory] [--file]
drupal config:import:single [--file] [--file]
Useful Configuration commands
drupal config:diff
drupal config:edit
drupal config:override
drupal config:delete
drupal debug:config
Override configuration per
environment
Configuration override system
There are cases when configuration values need to be overridden
for specific purposes as custom settings per environment.
For this cases the Drupal configuration systems provides the
configuration override system. This system allow you to override
configuration values.
https://www.drupal.org/node/1928898
Configuration override system
* Maintains these overrides as temporary layers on top of the
standard configuration values.
* Does not use overridden values for configuration forms.
* May store overrides with other configuration files for staging
and version control support.
https://www.drupal.org/node/1928898
Main web/sites/default/settings.php file
…
if (file_exists(__DIR__ . '/settings.environment.php')) {
include __DIR__ . '/settings.environment.php';
}
Main web/sites/default/settings.environment.php file
$env = getenv('ENVIRONMENT');
$base_path = $app_root . '/' . $site_path;
$servicesFile = $base_path . '/services.'.$env.'.yml';
$settingsFile = $base_path . '/settings.'.$env.'.php';
if (file_exists($servicesFile)) {
$settings['container_yamls'][] = $servicesFile;
}
if (file_exists($settingsFile)) {
include $settingsFile;
}
Using web/sites/default/services.develop.yml
parameters:
…
twig.config: { debug: true, auto_reload: true, cache: false }
…
services:
cache.backend.null:
class: DrupalCoreCacheNullBackendFactory
Using web/sites/default/settings.develop.php
<?php
$config['system.performance']['css']['preprocess'] = FALSE;
$config['system.performance']['js']['preprocess'] = FALSE;
require_once DRUPAL_ROOT . '/modules/contrib/devel/kint/kint/Kint.class.php';
Kint::$maxLevels = 5;
$settings['cache']['bins']['render'] = 'cache.backend.null';
$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';
Showing overridden configuration
# Pass the --show-overridden flag
drupal debug:config system.performance --show-overridden
Config Override Inspector
Config Override Inspector provides indicators to administrators
where form fields represent configuration that is overridden.
This module is especially useful for developers working on sites
where there are configuration overrides in place depending on the
environment. It prevents confusion that arise when changing a
form setting, but appears to not take effect.
https://www.drupal.org/project/coi
Install Drupal and import a
previously exported configuration.
Configuration Management
The Configuration Management (CM) system, is great. But
wouldn't it be even more awesome to be able to install a
site, export configuration and then re-install site from
scratch importing the previously exported configuration?
●
●
Install site and import previously exported configuration.
Not supported by Drupal out-of-the-box.
"Site UUID in source storage does not match the target
storage."
https://weknowinc.com/blog/how-install-drupal-8-existing-configuration
Why would you want to install your site from an existing configuration?
Automate the creation of reproducible build/artifacts from scratch at
any stage (Development, QA, Production) to test, launch or deploy
your site.
Simplify on-boarding for new developers to any project without the
need to obtain a database-dump. Developers will be able spin-up sites
from scratch just by installing the site and importing configuration files.
How to achieve this using Drupal Console? [ 1/2 ]
application:
...
 overrides:
   config:
     skip-validate-site-uuid: true
Simple as updating your console/config.yml adding:
How to achieve this using Drupal Console? [ 2/2 ]
drupal site:install --force —no-interaction
drupal config:import --no-interaction
Execute commands to install the site and import your previously
exported configuration:
Automate both commands
command:
 name: build:develop
 description: 'Build site by installing and importing configuration'
commands:
 # Install site
 - command: site:install
   options:
     force: true
   arguments:
     profile: standard
 # Import configurations
 - command: config:import
Using contributed modules to
improve configuration management.
Configuration Split
This module allows to define sets of configuration that will get
exported to separate directories when exporting, and get
merged together when importing.
https://www.drupal.org/project/config_split
Configuration Split | Export Configuration
# Export without development settings
drupal config:export
# Export including development settings
drupal config_split:export --split=develop
Configuration Split | Import Configuration
# Import without development settings
drupal config:import
# Import including development settings
drupal config_split:import --split=develop
Configuration Read-only mode
This module allows to lock any configuration changes done via
the Drupal admin UI. This can be useful in scenarios where for
example configuration changes should not be done on the
production environment, but only on specific environments.
https://www.drupal.org/project/config_readonly
Using web/sites/default/settings.production.php
if (PHP_SAPI !== 'cli') {
$settings['config_readonly'] = TRUE;
}
$settings['config_readonly_whitelist_patterns'] = [
‘system.site’,
‘views*',
‘blocks*',
];
Drupal hosting/deploying
alternatives PaaS
PaaS
Drupal deploy tools
Deploying site to a stage or
production server.
VPS
# 1st release
-- /var/www/my-app.com
|-- current -> /var/www/my-app.com/releases/20100509145325
|-- releases
| |-- 20100509145325
|-- shared
_______________________________________________________________________________
# 2nd release
-- /var/www/my-app.com
|-- current -> /var/www/my-app.com/releases/20100509150741
|-- releases
| |-- 20100509150741
| |-- 20100509145325
|-- shared
_______________________________________________________________________________
# 3rd release
-- /var/www/my-app.com
|-- current -> /var/www/my-app.com/releases/20100512131539
|-- releases
| |-- 20100512131539
| |-- 20100509150741
| |-- 20100509145325
|-- shared
Deploy via ssh to a server
Deployer
Deployer is a deployment tool written in
PHP with support for popular frameworks
out of the box.
Ansistrano (Ansible + Capistrano)
ansistrano.deploy and ansistrano.rollback are Ansible
Galaxy roles to easily manage the deployment process for
scripting applications such as PHP, Python and Ruby. It's an
Ansible port for Capistrano.
Docker in production
Improving your Drupal 8 development workflow DrupalCampLA
Kubernetes
> Create the Docker File(s).
> Build the image(s).
> Create a release tag.
> Push release to a public/private registry (dockerhub, quay, googlecloud).
> Orchestration Config pods, persistent volumes, services, etc.
Thank you … Questions?

More Related Content

PDF
Using Composer with Drupal and Drush
PPT
How a Content Delivery Network Can Help Speed Up Your Website
PDF
Speed up Drupal development with Drush
PDF
Composer Tools & Frameworks for Drupal
PDF
2014 hadoop wrocław jug
PDF
02 Hadoop deployment and configuration
PPTX
Drupal Overview For Techies
PPT
8a. How To Setup HBase with Docker
Using Composer with Drupal and Drush
How a Content Delivery Network Can Help Speed Up Your Website
Speed up Drupal development with Drush
Composer Tools & Frameworks for Drupal
2014 hadoop wrocław jug
02 Hadoop deployment and configuration
Drupal Overview For Techies
8a. How To Setup HBase with Docker

What's hot (16)

PPTX
Performance all teh things
PDF
Hive Quick Start Tutorial
PDF
Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016
PPT
Speeding Up The Snail
PDF
Terminus, the Pantheon command-line interface
PPTX
Drupal, varnish, esi - Toulouse November 2
PPT
Develop with linux containers and docker
PPTX
Hadoop single node setup
PDF
Streamline your development environment with docker
PPT
Local Drupal MultiSite Set-up
PDF
Cloudera hadoop installation
PPTX
Drupal in 5
PPT
11. From Hadoop to Spark 2/2
PDF
Hands on Docker - Launch your own LEMP or LAMP stack
PPTX
Apache Hadoop & Hive installation with movie rating exercise
PDF
features+
Performance all teh things
Hive Quick Start Tutorial
Help! I inherited a Drupal Site! - DrupalCamp Atlanta 2016
Speeding Up The Snail
Terminus, the Pantheon command-line interface
Drupal, varnish, esi - Toulouse November 2
Develop with linux containers and docker
Hadoop single node setup
Streamline your development environment with docker
Local Drupal MultiSite Set-up
Cloudera hadoop installation
Drupal in 5
11. From Hadoop to Spark 2/2
Hands on Docker - Launch your own LEMP or LAMP stack
Apache Hadoop & Hive installation with movie rating exercise
features+
Ad

Similar to Improving your Drupal 8 development workflow DrupalCampLA (20)

PDF
Introduction to Drupal - Installation, Anatomy, Terminologies
PDF
Face your fears: Drush and Aegir
PDF
Drupal 8 improvements for developer productivity php symfony and more
PDF
Drupal VM for Drupal 8 Dev - Drupal Camp STL 2017
PPTX
Drupal 8 - Improving your development workflow
PDF
Docman - The swiss army knife for Drupal multisite docroot management and dep...
PDF
Welcome aboard the team
PDF
Beginning Drush
PDF
Configuration as Dependency: Managing Drupal 8 Configuration with git and Com...
PDF
Building and Maintaining a Distribution in Drupal 7 with Features
PDF
Composer tools and frameworks for drupal.ppt
PDF
Composer tools and frameworks for Drupal
PPTX
Exploring composer in drupal 8 with drupal project - salva molina
PDF
Modernize Your Drupal Development
PDF
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
PPT
5 Important Tools for Drupal Development
ZIP
Building a Drupal Distribution using Features, Drush Make, Installation Profi...
PDF
Decoupling Drupal mit dem Lupus Nuxt.js Drupal Stack
PDF
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
PDF
Docker4Drupal 2.1 for Development
Introduction to Drupal - Installation, Anatomy, Terminologies
Face your fears: Drush and Aegir
Drupal 8 improvements for developer productivity php symfony and more
Drupal VM for Drupal 8 Dev - Drupal Camp STL 2017
Drupal 8 - Improving your development workflow
Docman - The swiss army knife for Drupal multisite docroot management and dep...
Welcome aboard the team
Beginning Drush
Configuration as Dependency: Managing Drupal 8 Configuration with git and Com...
Building and Maintaining a Distribution in Drupal 7 with Features
Composer tools and frameworks for drupal.ppt
Composer tools and frameworks for Drupal
Exploring composer in drupal 8 with drupal project - salva molina
Modernize Your Drupal Development
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
5 Important Tools for Drupal Development
Building a Drupal Distribution using Features, Drush Make, Installation Profi...
Decoupling Drupal mit dem Lupus Nuxt.js Drupal Stack
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
Docker4Drupal 2.1 for Development
Ad

More from Jesus Manuel Olivas (20)

PDF
Remix & GraphQL: A match made in heaven with type-safety DX
PDF
Drupal 10 Party GraphQL
PDF
How to use Drupal to create editorial experiences your content creators will...
PDF
Beyond Static: Building a Dynamic Application with Gatsby
PDF
Drupal, GraphQL, Views, View Modes and Gatsby for a US Gov site CMS Philly
PDF
Embracing the modern web using a Headless CMS with GatsbyJS CMS Philly
PDF
Embracing the modern web using a Headless CMS with GatsbyJS Stanford
PDF
Building a modern application using Symfony API Platform and GatsbyJS PHP QRO
PDF
Building a dynamic application with GatsbyJS-Tec-Mexicali
PDF
Building a modern web application in the cloud partnercon
PDF
Embracing the modern web using Drupal as a Headless CMS with Gatsby BADCamp
PDF
Blazing fast sites using Blaze, Hybrid CMS NYC
PDF
Embracing the modern web using Drupal as Headless CMS with GatsbyJS NYC
PDF
Writing a slack chatbot seattle
PDF
Building a Modern Web Application in the Cloud TecNerd
PDF
How to keep Drupal relevant in the Git-based and API-driven CMS era Florida
PDF
How to keep Drupal relevant in the Git-based and API-driven CMS era DrupalCampNJ
PDF
Tools and Projects Dec 2018 Edition
PDF
Creating a modern web application using Symfony API Platform Atlanta
PDF
How to keep Drupal relevant in the Git-based and API-driven CMS era - BADCamp
Remix & GraphQL: A match made in heaven with type-safety DX
Drupal 10 Party GraphQL
How to use Drupal to create editorial experiences your content creators will...
Beyond Static: Building a Dynamic Application with Gatsby
Drupal, GraphQL, Views, View Modes and Gatsby for a US Gov site CMS Philly
Embracing the modern web using a Headless CMS with GatsbyJS CMS Philly
Embracing the modern web using a Headless CMS with GatsbyJS Stanford
Building a modern application using Symfony API Platform and GatsbyJS PHP QRO
Building a dynamic application with GatsbyJS-Tec-Mexicali
Building a modern web application in the cloud partnercon
Embracing the modern web using Drupal as a Headless CMS with Gatsby BADCamp
Blazing fast sites using Blaze, Hybrid CMS NYC
Embracing the modern web using Drupal as Headless CMS with GatsbyJS NYC
Writing a slack chatbot seattle
Building a Modern Web Application in the Cloud TecNerd
How to keep Drupal relevant in the Git-based and API-driven CMS era Florida
How to keep Drupal relevant in the Git-based and API-driven CMS era DrupalCampNJ
Tools and Projects Dec 2018 Edition
Creating a modern web application using Symfony API Platform Atlanta
How to keep Drupal relevant in the Git-based and API-driven CMS era - BADCamp

Recently uploaded (20)

PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
KodekX | Application Modernization Development
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Encapsulation theory and applications.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Understanding_Digital_Forensics_Presentation.pptx
Empathic Computing: Creating Shared Understanding
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
KodekX | Application Modernization Development
NewMind AI Monthly Chronicles - July 2025
NewMind AI Weekly Chronicles - August'25 Week I
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Encapsulation_ Review paper, used for researhc scholars
Building Integrated photovoltaic BIPV_UPV.pdf
Unlocking AI with Model Context Protocol (MCP)
MYSQL Presentation for SQL database connectivity
Encapsulation theory and applications.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows

Improving your Drupal 8 development workflow DrupalCampLA

  • 1. Improving your Drupal 8 Development Workflow by Jesus Manuel Olivas / WeKnow
  • 2. Who I am? Jesus Manuel Olivas jmolivas@weknowinc.com jmolivas jmolivas http://drupal.org/u/jmolivas http://jmolivas.weknowinc.com
  • 7. Local environment. Isolate local machine from project dependencies. Easy and simple to start and continue working on existing projects. Facilitate on boarding and adding new team members. Project scope configurations. Shareable with the team using a code repository via git. Mimic production environment and other temporary stages.
  • 8. Local environment. ●OS Native, LAMP, Dev Desktop ●XAMPP => https://www.apachefriends.org ●MAMP => https://www.mamp.info/en/ ●WAMP => http://www.wampserver.com/en/ ●Vagrant => https://www.vagrantup.com/ ●Docker => https://www.docker.com/
  • 10. Local environment. DrupalVM => https://www.drupalvm.com/ Docksal => https://docksal.io/ DDEV => https://github.com/drud/ddev Lando => https://docs.devwithlando.io/ Outrigger => http://outrigger.sh/ Docker4Drupal => https://github.com/wodby/docker4drupal
  • 11. Ahoy
  • 12. Ahoy Ahoy is command line tool that gives each of your projects their own CLI app with with zero code and dependencies. http://www.ahoycli.com
  • 13. .ahoy.yml ahoyapi: v2 commands: up: cmd: docker-compose up -d "$@" usage: Create and start containers. down: cmd: docker-compose down "$@" usage: Stop and remove containers, networks, images, and volumes. composer: cmd: docker-compose exec --user=wodby php composer "$@" usage: Run Composer commands in the php service container. drupal: cmd: docker-compose exec --user=wodby php vendor/bin/drupal "$@" usage: Run Drupal Console commands in the php service container.
  • 15. Download Drupal (Composer) ● https://github.com/weknowinc/drupal-project (drupal.dev) ●# Includes configurations for Docker and DrupalConsole. ●composer create-project weknowinc/drupal-project /path/to/drupal # Clone project using git git clone git@github.com:weknowinc/drupal-project.git
  • 16. Manage environment variables (.env.dist => .env) # Copy env file cp .env.dist .env # Customize values
 vim .env
  • 17. What if this is not a new project? | How to automate this? # Create site alias, .env, and docker-compose.yml files. drupal dockerize (Available on 1.9.0 ETA TBD) # This will run drupal generate:site:alias drupal dotenv:init drupal docker:init
  • 19. Ignore configuration files (.gitignore) # External dependencies vendor # Drupal dependencies web/core web/modules/contrib web/themes/contrib web/profiles/contrib web/libraries/contrib # Files
 web/sites/*/files # env file .env # DB backups mariadb-init
  • 20. The new directory structure drupal.develop/ web/ ├── LICENSE ├── autoload.php ├── README.md ├── core ├── composer.json ├── index.php ├── composer.lock ├── modules ├── scripts ├── profiles ├── vendor ├── sites └── web └── themes
  • 21. Interact with containers # Start containers ahoy up # Stop containers ahoy down # Show logs ahoy logs <SERVICE_NAME> # Stop containers destroy data ahoy destroy
  • 22. docker-compose.yml | overview version: "2.x" services: mariadb: php: nginx: mailhog: traefik: volumes: mysqldata: driver: "local"
  • 23. Using Composer to manage project dependencies
  • 26. Using composer within the container Drupal 8 really takes a lot of advantages of using composer, you can install/uninstall dependencies and apply patches. Although it’s a good practice when using Docker, to run this commands inside your container because if you have a PHP version on your local machine, you could install dependencies that are not suitable for your container instance.
  • 27. Manage dependencies ahoy composer install ahoy composer update ahoy composer require drupal/admin_toolbar ahoy composer update drupal/admin_toolbar ahoy composer update drupal/admin_toolbar --with-dependencies ahoy composer remove drupal/admin_toolbar
  • 28. Composer commands ahoy composer why drupal/admin_toolbar ahoy composer show [-o] [drupal/admin_toolbar] ahoy composer check-platform-reqs ahoy composer diagnose
  • 29. How composer know about Drupal dependencies "repositories": [ { "type": "composer", "url": "https://packages.drupal.org/8" } ],
  • 30. How composer know where to download dependencies "extra": { "installer-paths": { "docroot/core": [ "type:drupal-core" ], "docroot/modules/contrib/{$name}": [ "type:drupal-module" ], "docroot/theme/contrib/{$name}": [ “type:drupal-theme" ] } }
  • 31. Apply patches (composer.json) "extra": { "patches": { "drupal/admin_toolbar": { "Patch description": “URL/local path to patch" } } } ● https://github.com/cweagans/composer-patches
  • 32. Composer configuration "minimum-stability": "dev", "prefer-stable": true, "config": { "platform": { "php": "7.0", "sort-packages": true } }
  • 34. Register a drupal-library (composer.json) "repositories": [ { "type": "package", "package": { "name": "ckeditor/codesnippet", "description": "This plugin …", "type": "drupal-library", "homepage": "https://ckeditor.com/cke4/addon/codesnippet", "version": “4.7.3”, "dist": { "type": "zip", "url": "https://download.ckeditor.com/codesnippet/releases/codesnippet_4.7.3.zip", "reference": "master" } } } ],
  • 35. Download a drupal-library (composer) composer require ckeditor/codesnippet # composer.json "extra": { "installer-paths": { "web/libraries/{$name}": [ “type:drupal-library" ], } }
  • 38. Drupal Console Launcher https://docs.drupalconsole.com/en/getting/launcher.html curl https://drupalconsole.com/installer -L -o drupal.phar mv drupal.phar /usr/local/bin/drupal chmod +x /usr/local/bin/drupal
  • 39. Why do I need the Launcher? This is a global executable that enables you to run the command, drupal, from any directory within your site's project. Without it you will be inconvenienced by having to run the command only from your drupal root directory. For example, if you have Drupal root in a /web directory, and a composer.json and your vendor directory in the directory above that, you will be able to run the drupal command from the same directory as the composer.json file. Even better, you can run it from any subdirectory under that as many levels deep as you would like to go. https://docs.drupalconsole.com/en/getting/project.html
  • 40. Drupal Console per-site installation composer require drupal/console:~1.0 --prefer-dist --optimize-autoloader ●https://docs.drupalconsole.com/en/getting/composer.html
  • 41. Site alias ● https://docs.drupalconsole.com/en/alias/using-site-alias.html Drupal Console allows you to run commands from your local server but being able to execute those commands on a local, remote (VPS, PaaS) or virtual (VM, Docker) Drupal installation using site aliases. A site alias file use the YAML format to provide a collection of predefined options. Once an alias is defined you can call them using a short name.
  • 42. Site alias console/sites/drupal.yml (container | docker4drupal) develop: root: /var/www/html extra-options: docker-compose exec --user=82 php type: container ● https://docs.drupalconsole.com/en/alias/connecting-to-a-virtual-environment.html
  • 43. Site alias console/sites/drupal.yml (ssh | drupalvm) drupalvm: root: /var/www/drupalvm/drupal host: 192.168.88.88 user: vagrant extra-options: '-o PasswordAuthentication=no -i ~/.vagrant.d/insecure_private_key' type: ssh ● https://docs.drupalconsole.com/en/alias/connecting-to-a-virtual-environment.html
  • 44. Execute Drupal Console using site alias # Using the --target option
 drupal --target=drupal.develop cr all # Using the legacy @ identifier drupal @drupal.develop cr all
  • 45. Configuration Management Managing configuration changes through the CLI. Install Drupal and import a previously exported configuration. Override configuration per environment Content synchronization.
  • 47. Configuration Management In Drupal, configuration is the collection of admin settings that determine how the site functions, as opposed to the content of the site. Configuration will typically include things such as the site name, the content types and fields, taxonomy vocabularies, views and so on.
  • 48. Configuration system The Drupal configuration system handles configuration in a unified manner. By default, Drupal stores configuration data in the database, but it can be exported to YAML files, allowing the configuration to be managed by version control.
  • 49. Configuration Management Configuration is a mapping of keys and values. Stored on the Database by default. Exported as YAML for synchronization between environments. Once a module is installed the configuration provided by the module is owned by the site not the by the module anymore.
  • 50. Exporting Configuration drupal config:export drupal config:export [--directory] [--tar] drupal config:export:single [--directory] [--module] drupal config:export:content:type drupal config:export:view
  • 51. Importing Configuration drupal config:import drupal config:import [--file] [--directory] drupal config:import:single [--directory] [--file] drupal config:import:single [--file] [--file]
  • 52. Useful Configuration commands drupal config:diff drupal config:edit drupal config:override drupal config:delete drupal debug:config
  • 54. Configuration override system There are cases when configuration values need to be overridden for specific purposes as custom settings per environment. For this cases the Drupal configuration systems provides the configuration override system. This system allow you to override configuration values. https://www.drupal.org/node/1928898
  • 55. Configuration override system * Maintains these overrides as temporary layers on top of the standard configuration values. * Does not use overridden values for configuration forms. * May store overrides with other configuration files for staging and version control support. https://www.drupal.org/node/1928898
  • 56. Main web/sites/default/settings.php file … if (file_exists(__DIR__ . '/settings.environment.php')) { include __DIR__ . '/settings.environment.php'; }
  • 57. Main web/sites/default/settings.environment.php file $env = getenv('ENVIRONMENT'); $base_path = $app_root . '/' . $site_path; $servicesFile = $base_path . '/services.'.$env.'.yml'; $settingsFile = $base_path . '/settings.'.$env.'.php'; if (file_exists($servicesFile)) { $settings['container_yamls'][] = $servicesFile; } if (file_exists($settingsFile)) { include $settingsFile; }
  • 58. Using web/sites/default/services.develop.yml parameters: … twig.config: { debug: true, auto_reload: true, cache: false } … services: cache.backend.null: class: DrupalCoreCacheNullBackendFactory
  • 59. Using web/sites/default/settings.develop.php <?php $config['system.performance']['css']['preprocess'] = FALSE; $config['system.performance']['js']['preprocess'] = FALSE; require_once DRUPAL_ROOT . '/modules/contrib/devel/kint/kint/Kint.class.php'; Kint::$maxLevels = 5; $settings['cache']['bins']['render'] = 'cache.backend.null'; $settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';
  • 60. Showing overridden configuration # Pass the --show-overridden flag drupal debug:config system.performance --show-overridden
  • 61. Config Override Inspector Config Override Inspector provides indicators to administrators where form fields represent configuration that is overridden. This module is especially useful for developers working on sites where there are configuration overrides in place depending on the environment. It prevents confusion that arise when changing a form setting, but appears to not take effect. https://www.drupal.org/project/coi
  • 62. Install Drupal and import a previously exported configuration.
  • 63. Configuration Management The Configuration Management (CM) system, is great. But wouldn't it be even more awesome to be able to install a site, export configuration and then re-install site from scratch importing the previously exported configuration?
  • 64.
  • 65.
  • 66. Install site and import previously exported configuration. Not supported by Drupal out-of-the-box. "Site UUID in source storage does not match the target storage." https://weknowinc.com/blog/how-install-drupal-8-existing-configuration
  • 67. Why would you want to install your site from an existing configuration? Automate the creation of reproducible build/artifacts from scratch at any stage (Development, QA, Production) to test, launch or deploy your site. Simplify on-boarding for new developers to any project without the need to obtain a database-dump. Developers will be able spin-up sites from scratch just by installing the site and importing configuration files.
  • 68. How to achieve this using Drupal Console? [ 1/2 ] application: ...  overrides:    config:      skip-validate-site-uuid: true Simple as updating your console/config.yml adding:
  • 69. How to achieve this using Drupal Console? [ 2/2 ] drupal site:install --force —no-interaction drupal config:import --no-interaction Execute commands to install the site and import your previously exported configuration:
  • 70. Automate both commands command:  name: build:develop  description: 'Build site by installing and importing configuration' commands:  # Install site  - command: site:install    options:      force: true    arguments:      profile: standard  # Import configurations  - command: config:import
  • 71. Using contributed modules to improve configuration management.
  • 72. Configuration Split This module allows to define sets of configuration that will get exported to separate directories when exporting, and get merged together when importing. https://www.drupal.org/project/config_split
  • 73. Configuration Split | Export Configuration # Export without development settings drupal config:export # Export including development settings drupal config_split:export --split=develop
  • 74. Configuration Split | Import Configuration # Import without development settings drupal config:import # Import including development settings drupal config_split:import --split=develop
  • 75. Configuration Read-only mode This module allows to lock any configuration changes done via the Drupal admin UI. This can be useful in scenarios where for example configuration changes should not be done on the production environment, but only on specific environments. https://www.drupal.org/project/config_readonly
  • 76. Using web/sites/default/settings.production.php if (PHP_SAPI !== 'cli') { $settings['config_readonly'] = TRUE; } $settings['config_readonly_whitelist_patterns'] = [ ‘system.site’, ‘views*', ‘blocks*', ];
  • 78. PaaS
  • 80. Deploying site to a stage or production server.
  • 81. VPS
  • 82. # 1st release -- /var/www/my-app.com |-- current -> /var/www/my-app.com/releases/20100509145325 |-- releases | |-- 20100509145325 |-- shared _______________________________________________________________________________ # 2nd release -- /var/www/my-app.com |-- current -> /var/www/my-app.com/releases/20100509150741 |-- releases | |-- 20100509150741 | |-- 20100509145325 |-- shared _______________________________________________________________________________ # 3rd release -- /var/www/my-app.com |-- current -> /var/www/my-app.com/releases/20100512131539 |-- releases | |-- 20100512131539 | |-- 20100509150741 | |-- 20100509145325 |-- shared Deploy via ssh to a server
  • 83. Deployer Deployer is a deployment tool written in PHP with support for popular frameworks out of the box.
  • 84. Ansistrano (Ansible + Capistrano) ansistrano.deploy and ansistrano.rollback are Ansible Galaxy roles to easily manage the deployment process for scripting applications such as PHP, Python and Ruby. It's an Ansible port for Capistrano.
  • 87. Kubernetes > Create the Docker File(s). > Build the image(s). > Create a release tag. > Push release to a public/private registry (dockerhub, quay, googlecloud). > Orchestration Config pods, persistent volumes, services, etc.
  • 88. Thank you … Questions?