SlideShare a Scribd company logo
1 of 99
Download to read offline
Drupal 8
Configuration Management
Phil Norton
Drupal Camp Yorkshire 2014
DrupalCamp Yorkshire 2014
Me
• Phil Norton (@philipnorton42)
• #! code (www.hashbangcode.com)
• Technical Lead at Access
• Help run NWDUG
What Is Drupal
Config?
!
A quick quiz
Blog post
Permissions
Vocabulary
Taxonomy term
Field definition
Menu
Variable
Menu item
User
Contents of a block
Configuration Content
Blog Post
!
Taxonomy Term
!
Menu Item
!
Block Content
Permissions
!
Field Definition
!
Vocabulary
!
Menu
!
Variable
TAC
!
Webform
!
Default
Content
!
Views
Configuration Content
Blog Post
!
Taxonomy Term
!
Menu Item
!
Block Content
Permissions
!
Field Definition
!
Vocabulary
!
Menu
!
Variable
TAC
!
Webform
!
Default
Content
!
Views
Content
!
!
Session
!
!
State
!
!
Configuration
An article page, uploaded files
Logged in status, shopping carts
Last cron run
Everything else
Challenge
• Developer:
• Wants to work on code
• Wants to change the config
• Wants to deploy across environments
• Client:
• Wants to work on content
• Doesn’t want to lose work
Current Situation
Drupal 7 Configuration
• Features
• Install/Update hooks
• Install Profiles
How do we currently manage configuration in Drupal?
Features
• Export and import of certain configurations as
modules
• Not all modules supported so there tends to be
gaps in the configuration
• Adding Features support for modules is not easy
• Features ‘Overridden’ sadness
Install/Update Hooks
• Create tables
• Set up variables
• Fill in ‘gaps’ in Features modules
Install Profiles
• Combine Features modules and install hooks
• Full site setup out of the box
• Limited Drupal API available
• Doesn’t always work as planned
What’s Next In
Drupal 8?
Drupal 8 Initiatives
• Configuration Management
• Web Services
• Multilingual
• HTML 5
• Mobile
CMI
Configuration Management Initiative
http://bit.ly/1tDBbsA
!
http://drupal8cmi.org
CMI
• Lead by Greg Dunlap - (heyrocker)
Also involved are:
• Joel Farris (senpai)
• Jonathan Lambert (jlambert)
• David Strauss (davidstrauss)
• Larry Garfield (crell)
• Karoly Negeyesi (chx)
• Angie Byron (webchick)
• Alex Pott (alexpott)
• And many others…
CMI
To build Drupal from the ground up to be better at
configuration management
CMI
• Move configuration management into core
• Allow storage of configuration in files
• Allow the transfer of configuration between
environments
• Create an API to allow custom configurations
• Integrate UUID into core so certain configurations
can be given machine names
Usage
Behind The Scenes
• Active configuration is stored in the database
• Clicking Export collates the configuration that each
module defines and combines it with the current
active configuration
• Export contains the active configuration in the form
of YAML files
Behind The Scenes
• YAML files are used to store the configuration
• A ‘staging’ and an ‘active’ directory are defined in
settings.php
• Used to store and compare the current
configuration
• By default the directories are stored in the location

/sites/default/files/config_<hash>/
active
• Originally intended to be used as the location of the
active configuration
• Active configuration is now stored in the database
• Configuration development module (https://
drupal.org/project/config_devel)
staging
• Stores current imported configuration as YAML files
• Shows difference between configuration changes
• Changes made here can be imported into active
configuration
YAML!
YAML Ain't Markup Language
!
(Yet Another Markup Language)
YAML
• Data orientated format
• Has several benefits over other formats like INI,
JSON, XML
• Support for hierarchical values
• Lists and associative arrays possible
• Used extensively in Drupal 8
YAML
• Simple values defined by
key: value
• Hierarchical values defined with whitespace
keys:
key1: value
key2: value
YAML
Comments start the line with a ‘#’
!
# This is a comment
item: value
YAML Lists
!
- item1
- item2
- item3
!
!
[item1, item2, item3]
!
!
- {name: 'webserver1', ip: ‘192.168.100.100’}
- {name: 'webserver2', ip: ‘192.168.100.101’}
- {name: 'webserver3', ip: ‘192.168.100.102’}
uuid: ''	
name: Drupal	
mail: ''	
slogan: ''	
page:	
403: ''	
404: ''	
front: user	
admin_compact_mode: false	
weight_select_max: 100	
langcode: en
core/modules/system/config/install/system.site.yml
YAML Filenames In Drupal 8
• < module >.< component >.yml



system.settings.yml

views.settings.yml
• < module >.< component >.< entity >.yml



image.style.medium.yml

views.view.content.yml
Configuration API
Configuration Schema
• Needed to define what your configuration will hold
• Kwalify inspired format
• Used to define what types of data the configuration
will contain
• See more at: https://drupal.org/node/1905070
system.schema.yml
system.site:	
type: mapping	
label: 'Site information'	
mapping:	
uuid:	
type: string	
label: 'Site UUID'	
name:	
type: label	
label: 'Site name'	
mail:	
type: email	
label: 'E-mail address'	
slogan:	
type: label	
label: 'Slogan'	
page:	
type: mapping	
label: 'Pages'	
mapping:	
403:	
type: path	
label: 'Default 403 (access denied) page'	
404:	
type: path	
label: 'Default 404 (not found) page'	
front:	
type: path	
label: 'Default front page'	
admin_compact_mode:	
type: boolean	
label: 'Compact mode'	
weight_select_max:	
type: integer	
label: 'Weight element maximum value'	
langcode:	
type: string	
label: 'Default language'
system.schema.yml
system.site:	
type: mapping	
label: 'Site information'	
mapping:	
uuid:	
type: string	
label: 'Site UUID'	
name:	
type: label	
label: 'Site name'	
Schema name
Also shows the
configuration
filename
“system.site.yml”
Used to reference
this configuration
system.schema.yml
system.site:	
type: mapping	
label: 'Site information'	
mapping:	
uuid:	
type: string	
label: 'Site UUID'	
name:	
type: label	
label: 'Site name'	
Container
data type
‘mapping’ is for
key value sets
allows for
associative arrays
of different data
types
system.schema.yml
system.site:	
type: mapping	
label: 'Site information'	
mapping:	
uuid:	
type: string	
label: 'Site UUID'	
name:	
type: label	
label: 'Site name'	
Label
Used as an
interface label
system.schema.yml
system.site:	
type: mapping	
label: 'Site information'	
mapping:	
uuid:	
type: string	
label: 'Site UUID'	
name:	
type: label	
label: 'Site name'	
Start of
mapping section
item key
item type
item label
Simple Configuration
• Can be single values or arrays of values
• Used to store global configuration options
• Easy to implement:
• Create schema YAML file in 

< module >/config/install/schema
• Create config YAML file 

< module >/config/install
Getting Configuration
uuid: ''	
name: Drupal	
mail: ''	
slogan: ''	
page:	
403: ''	
404: ''	
front: user	
admin_compact_mode: false	
weight_select_max: 100	
langcode: en	
!
!
$config = Drupal::config('system.site');

$email = $config->get('mail');

!
$cofig = Drupal::config(‘system.site')	
$page403 = $config->get('page.403');



Getting Configuration
uuid: ''	
name: Drupal	
mail: ''	
slogan: ''	
page:	
403: ''	
404: ''	
front: user	
admin_compact_mode: false	
weight_select_max: 100	
langcode: en	
!
!
$email = Drupal::config('system.site')->get('mail');

!
$page403 = Drupal::config('system.site')->get('page.403');



!
Setting Configuration
$config = Drupal::config('system.site');

$config->set(‘mail’, ‘test@example.com’);

$config->save();

!
!
$config = Drupal::config(‘system.site’)->set('mail',
‘test@example.com’);

$config->save();	
!
!


Drupal::config(‘system.site’)->set('mail', ‘test@example.com)-
>save();
Clear Configuration
$config = Drupal::config('system.site');	
$config->clear('mail')->save();





!
Drupal::config('system.site')->delete();
Configuration Entities
• Used to store custom entity configurations
• More complex and therefore harder to implement
• Used for configurations that have multiple entries

Example: Views, Image cache settings, Contact
form categories
Contact Category Interface
namespace Drupalcontact;	
!
use DrupalCoreConfigEntityConfigEntityInterface;	
!
/**	
* Provides an interface defining a contact category entity.	
*/	
interface CategoryInterface extends ConfigEntityInterface {	
!
}
Contact Category Entity
namespace DrupalcontactEntity;	
!
use DrupalCoreConfigEntityConfigEntityBase;	
use DrupalCoreEntityEntityStorageInterface;	
use DrupalcontactCategoryInterface;	
!
/**	
* Defines the contact category entity.	
*	
* @ConfigEntityType(	
* id = "contact_category",	
* label = @Translation("Contact category"),	
* controllers = {	
* "access" = "DrupalcontactCategoryAccessController",	
* "list_builder" = "DrupalcontactCategoryListBuilder",	
* "form" = {	
* "add" = "DrupalcontactCategoryForm",	
* "edit" = "DrupalcontactCategoryForm",	
* "delete" = "DrupalcontactFormCategoryDeleteForm"	
* }	
* },	
* config_prefix = "category",	
* admin_permission = "administer contact forms",	
* bundle_of = "contact_message",	
* entity_keys = {	
* "id" = "id",	
* "label" = "label"	
* },	
* links = {	
* "delete-form" = "contact.category_delete",	
* "edit-form" = "contact.category_edit"	
* }	
* )	
*/	
class Category extends ConfigEntityBase implements CategoryInterface {
class Category extends ConfigEntityBase implements CategoryInterface {	
!
/**	
* The category ID.	
*	
* @var string	
*/	
public $id;	
!
/**	
* The category label.	
*	
* @var string	
*/	
public $label;	
!
/**	
* List of recipient e-mail addresses.	
*	
* @var array	
*/	
public $recipients = array();	
!
/**	
* An auto-reply message to send to the message author.	
*	
* @var string	
*/	
public $reply = '';	
!
/**	
* Weight of this category (used for sorting).	
*	
* @var int	
*/	
public $weight = 0;
contact.category.personal.yml
id: personal	
label: 'Personal contact form'	
recipients: { }	
reply: ''	
weight: 0	
status: true	
uuid: 43155e41-8a58-4264-ab00-be97a0736aa0	
langcode: en	
dependencies: { }	
!
!
$contact_category = $this->entityManager()	
->getStorage('contact_category')	
->load('personal');	
!
$contact_category->label();
contact.category.personal.yml
id: personal	
label: 'Personal contact form'	
recipients: { }	
reply: ''	
weight: 0	
status: true	
uuid: 43155e41-8a58-4264-ab00-be97a0736aa0	
langcode: en	
dependencies: { }	
!
!
$config = Drupal::config('contact.category.personal')->get();	
$label = $config['label'];	
!
$label = Drupal::config(‘contact.category.personal')->get('label');
Drush
• Full Drush integration available
• Need Drush version 7.x
• Currently in dev branch of Drush
• List of Drush commands:

http://www.drushcommands.com/drush-7x/config/
config-list
Drush
Export config from the active configuration to the
staging directory



drush config-export



drush cex
Drush
Import the staging configuration into the active
configuration



drush config-import



drush cim
Workflow
• Staging config should become part of your
codebase
• New configuration changes should be exported
and integrated into code base
• Configuration in code should then be used to move
configuration between servers
Dev Stage Live
export
deploy deploy
import import
Git
Config
Code
Git
Config
Code
Git
Config
Code
Workflow
Dev Stage Live
drush cex
deploy deploy
drush cim drush cim
Git
Config
Code
Git
Config
Code
Git
Config
Code
Drush Workflow
Roll Your Own
Configurations
!
!
!
!
Create a module that stores simple configurations
MyModule
• A module that integrates with the configuration
management API
• Defines a single configuration item
• Defines a page to display the configuration
• Defines a form to change the configuration
MyModule Configuration
• mymodule.info.yml file defines the module
• mymodule.settings.yml contains the module
configuration
• mymodule.schema.yml contains information about
the configuration item being defined
• mymodule.routing.yml defines routes to a page and
a form
name: 'MyModule'	
type: module	
description: 'My module'	
version: VERSION	
core: 8.x
mymodule.info.yml
configitem: ''
/config/install/mymodule.settings.yml
mymodule.settings:	
type: mapping	
label: 'My Module Settings'	
mapping:	
configitem:	
type: string	
label: 'A config item'
/config/schema/mymodule.schema.yml
mymodule.page:	
path: '/mymodule'	
defaults:	
_content: 'DrupalmymoduleController
MyModuleController::description'	
requirements:	
_access: 'TRUE'	
!
mymodule.admin:	
path: '/mymodule/edit'	
defaults:	
_form: 'DrupalmymoduleFormMyModuleAdminForm'	
requirements:	
_access: 'TRUE'
mymodule.routing.yml
MyModule Page
• mymodule.routing.yml defines the route to the page
• Destination MyModuleController::description()
loads the configuration and displays it
namespace DrupalmymoduleController;	
!
use DrupalCoreControllerControllerBase;	
!
/**	
* Custom page.	
*/	
class MyModuleController extends ControllerBase {	
!
/**	
* An example page.	
*	
* @return string	
* A render array containing some page content.	
*/	
public function description() {	
!
$mymodule_config = Drupal::config('mymodule.settings');	
!
$output = array();	
!
$output['mymodule_output'] = array(	
'#markup' => t('The value of configitem is "!configitem"', array('!configitem' =>
$mymodule_config->get('configitem')))	
);	
!
return $output;	
}	
}
lib/Drupal/mymodule/Controller/MyModuleController.php
MyModule Form
• mymodule.routing.yml defines the route to the form
• Class MyModuleAdminForm defines a form that
loads the configuration
• Configuration is saved upon submission of the form
namespace DrupalmymoduleForm;	
!
use DrupalCoreFormConfigFormBase;	
!
/**	
* Configure MyModule admin settings for this site.	
*/	
class MyModuleAdminForm extends ConfigFormBase {	
!
/**	
* Implements DrupalCoreFormFormInterface::getFormID().	
*/	
public function getFormID() {	
return 'mymodule_edit_form';	
}	
!
/**	
* Implements DrupalCoreFormFormInterface::buildForm().	
*/	
public function buildForm(array $form, array &$form_state) {	
$config = $this->configFactory()->get('mymodule.settings');	
!
$form['configitem'] = array(	
'#type' => 'textfield',	
'#title' => t('Config Settings'),	
'#default_value' => $config->get('configitem')	
);	
!
return parent::buildForm($form, $form_state);	
}	
!
/**	
* Implements DrupalCoreFormFormInterface::submitForm().	
*/	
public function submitForm(array &$form, array &$form_state) {	
$config = $this->configFactory()->get('mymodule.settings');	
!
$config->set('configitem', $form_state['values']['configitem'])->save();	
!
parent::submitForm($form, $form_state);	
}	
}
lib/Drupal/mymodule/Form/MyModuleAdminForm.php
!
/**	
* Implements DrupalCoreFormFormInterface::buildForm().	
*/	
public function buildForm(array $form, array &$form_state) {	
$config = $this->configFactory()->get('mymodule.settings');	
!
$form['configitem'] = array(	
'#type' => 'textfield',	
'#title' => t('Config Settings'),	
'#default_value' => $config->get('configitem')	
);	
!
return parent::buildForm($form, $form_state);	
}	
lib/Drupal/mymodule/Form/MyModuleAdminForm.php
!
!
/**	
* Implements DrupalCoreFormFormInterface::submitForm().	
*/	
public function submitForm(array &$form, array &$form_state) {	
$config = $this->configFactory()->get('mymodule.settings');	
!
$config->set('configitem', $form_state['values']['configitem'])->save();	
!
parent::submitForm($form, $form_state);	
}
lib/Drupal/mymodule/Form/MyModuleAdminForm.php
configitem: 'another value'
Drupal 7
• Configuration management has been back ported
into Drupal 7
• Configuration Management module 

https://drupal.org/project/configuration
Resources
• Creating Drupal 8.x modules

https://drupal.org/developing/modules/8
!
• Configuration API in Drupal 8

https://drupal.org/node/1667894
!
• Understanding Drupal 8's config entities

http://www.previousnext.com.au/blog/understanding-drupal-8s-config-entities
!
• Configuration schema/metadata

https://drupal.org/node/1905070
!
• Configuration inspector for Drupal 8

https://drupal.org/project/config_inspector
Drupal 8 CMI Needs You!
• Lots of work still needs to be done on CMI
• Go to http://drupal8cmi.org/ and pick an issue to
work on
Me
• Phil Norton (@philipnorton42)
• #! code (www.hashbangcode.com)
• Technical Lead at Access
• Help run NWDUG

More Related Content

What's hot

Becoming A Drupal Master Builder
Becoming A Drupal Master BuilderBecoming A Drupal Master Builder
Becoming A Drupal Master BuilderPhilip Norton
 
Drupal 8 Services And Dependency Injection
Drupal 8 Services And Dependency InjectionDrupal 8 Services And Dependency Injection
Drupal 8 Services And Dependency InjectionPhilip Norton
 
Introduction to Module Development (Drupal 7)
Introduction to Module Development (Drupal 7)Introduction to Module Development (Drupal 7)
Introduction to Module Development (Drupal 7)April Sides
 
Getting Into Drupal 8 Configuration
Getting Into Drupal 8 ConfigurationGetting Into Drupal 8 Configuration
Getting Into Drupal 8 ConfigurationPhilip Norton
 
Drupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentDrupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentsparkfabrik
 
ExtBase workshop
ExtBase workshop ExtBase workshop
ExtBase workshop schmutt
 
Hive Quick Start Tutorial
Hive Quick Start TutorialHive Quick Start Tutorial
Hive Quick Start TutorialCarl Steinbach
 
Working with Hive Analytics
Working with Hive AnalyticsWorking with Hive Analytics
Working with Hive AnalyticsManish Chopra
 
Introduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, TerminologiesIntroduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, TerminologiesGerald Villorente
 
Build Amazing Add-ons for Atlassian JIRA and Confluence
Build Amazing Add-ons for Atlassian JIRA and ConfluenceBuild Amazing Add-ons for Atlassian JIRA and Confluence
Build Amazing Add-ons for Atlassian JIRA and ConfluenceK15t
 
DSpace 4.2 Basics & Configuration
DSpace 4.2 Basics & ConfigurationDSpace 4.2 Basics & Configuration
DSpace 4.2 Basics & ConfigurationDuraSpace
 
Managing themes and server environments with extensible configuration arrays
Managing themes and server environments with extensible configuration arraysManaging themes and server environments with extensible configuration arrays
Managing themes and server environments with extensible configuration arraysChris Olbekson
 
Making DSpace XMLUI Your Own
Making DSpace XMLUI Your OwnMaking DSpace XMLUI Your Own
Making DSpace XMLUI Your OwnTim Donohue
 
Drupal 8 Theme System: The Backend of Frontend
Drupal 8 Theme System: The Backend of FrontendDrupal 8 Theme System: The Backend of Frontend
Drupal 8 Theme System: The Backend of FrontendAcquia
 
DDAY2014 - Features per Drupal 8
DDAY2014 - Features per Drupal 8DDAY2014 - Features per Drupal 8
DDAY2014 - Features per Drupal 8DrupalDay
 

What's hot (20)

Becoming A Drupal Master Builder
Becoming A Drupal Master BuilderBecoming A Drupal Master Builder
Becoming A Drupal Master Builder
 
Drupal 8 Services And Dependency Injection
Drupal 8 Services And Dependency InjectionDrupal 8 Services And Dependency Injection
Drupal 8 Services And Dependency Injection
 
Drupal 8 Services
Drupal 8 ServicesDrupal 8 Services
Drupal 8 Services
 
Introduction to Module Development (Drupal 7)
Introduction to Module Development (Drupal 7)Introduction to Module Development (Drupal 7)
Introduction to Module Development (Drupal 7)
 
Getting Into Drupal 8 Configuration
Getting Into Drupal 8 ConfigurationGetting Into Drupal 8 Configuration
Getting Into Drupal 8 Configuration
 
Drupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentDrupal 8 - Corso frontend development
Drupal 8 - Corso frontend development
 
ExtBase workshop
ExtBase workshop ExtBase workshop
ExtBase workshop
 
Hive Quick Start Tutorial
Hive Quick Start TutorialHive Quick Start Tutorial
Hive Quick Start Tutorial
 
Working with Hive Analytics
Working with Hive AnalyticsWorking with Hive Analytics
Working with Hive Analytics
 
Introduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, TerminologiesIntroduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, Terminologies
 
Build Amazing Add-ons for Atlassian JIRA and Confluence
Build Amazing Add-ons for Atlassian JIRA and ConfluenceBuild Amazing Add-ons for Atlassian JIRA and Confluence
Build Amazing Add-ons for Atlassian JIRA and Confluence
 
Beginning hive and_apache_pig
Beginning hive and_apache_pigBeginning hive and_apache_pig
Beginning hive and_apache_pig
 
Drupal 8 Configuration Management
Drupal 8 Configuration ManagementDrupal 8 Configuration Management
Drupal 8 Configuration Management
 
DSpace 4.2 Basics & Configuration
DSpace 4.2 Basics & ConfigurationDSpace 4.2 Basics & Configuration
DSpace 4.2 Basics & Configuration
 
Changelog
ChangelogChangelog
Changelog
 
Managing themes and server environments with extensible configuration arrays
Managing themes and server environments with extensible configuration arraysManaging themes and server environments with extensible configuration arrays
Managing themes and server environments with extensible configuration arrays
 
Making DSpace XMLUI Your Own
Making DSpace XMLUI Your OwnMaking DSpace XMLUI Your Own
Making DSpace XMLUI Your Own
 
Drupal 8 Theme System: The Backend of Frontend
Drupal 8 Theme System: The Backend of FrontendDrupal 8 Theme System: The Backend of Frontend
Drupal 8 Theme System: The Backend of Frontend
 
DDAY2014 - Features per Drupal 8
DDAY2014 - Features per Drupal 8DDAY2014 - Features per Drupal 8
DDAY2014 - Features per Drupal 8
 
Migrate in Drupal 8
Migrate in Drupal 8Migrate in Drupal 8
Migrate in Drupal 8
 

Similar to Drupal 8 Configuration Management

Config management
Config managementConfig management
Config managementAlexei Goja
 
Staying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHPStaying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHPOscar Merida
 
Manage Deployments with Install Profiles and Git
Manage Deployments with Install Profiles and GitManage Deployments with Install Profiles and Git
Manage Deployments with Install Profiles and Gitnhepner
 
Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3Drupalcon Paris
 
Staying Sane with Drupal (A Develper's Survival Guide)
Staying Sane with Drupal (A Develper's Survival Guide)Staying Sane with Drupal (A Develper's Survival Guide)
Staying Sane with Drupal (A Develper's Survival Guide)Oscar Merida
 
Get things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGet things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGiuliano Iacobelli
 
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...LEDC 2016
 
Migrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mindMigrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mindValentine Matsveiko
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineYared Ayalew
 
Drupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp BratislavaDrupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp BratislavaGábor Hojtsy
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO DevsWO Community
 
Magento performance feat. core Hacks
Magento performance feat. core HacksMagento performance feat. core Hacks
Magento performance feat. core HacksDaniel Niedergesäß
 
Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Angela Byron
 
The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)Paul Jones
 
Rapid Application Development with CakePHP 1.3
Rapid Application Development with CakePHP 1.3Rapid Application Development with CakePHP 1.3
Rapid Application Development with CakePHP 1.3kidtangerine
 
Blue Green Sitecore Deployments on Azure
Blue Green Sitecore Deployments on AzureBlue Green Sitecore Deployments on Azure
Blue Green Sitecore Deployments on AzureRob Habraken
 
Creating Custom Templates for Joomla! 2.5
Creating Custom Templates for Joomla! 2.5Creating Custom Templates for Joomla! 2.5
Creating Custom Templates for Joomla! 2.5Don Cranford
 
Drupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First StepsDrupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First StepsLuís Carneiro
 
Reactive summit 2020 microsoft orleans the easy way
Reactive summit 2020   microsoft orleans the easy wayReactive summit 2020   microsoft orleans the easy way
Reactive summit 2020 microsoft orleans the easy wayJohn Azariah
 

Similar to Drupal 8 Configuration Management (20)

Config management
Config managementConfig management
Config management
 
Staying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHPStaying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHP
 
Manage Deployments with Install Profiles and Git
Manage Deployments with Install Profiles and GitManage Deployments with Install Profiles and Git
Manage Deployments with Install Profiles and Git
 
Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3
 
Staying Sane with Drupal (A Develper's Survival Guide)
Staying Sane with Drupal (A Develper's Survival Guide)Staying Sane with Drupal (A Develper's Survival Guide)
Staying Sane with Drupal (A Develper's Survival Guide)
 
Get things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGet things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplications
 
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
Валентин Мацвейко та Владислав Мойсеєнко — D8: Migrate Yourself: code->module...
 
Migrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mindMigrate yourself. code -> module -> mind
Migrate yourself. code -> module -> mind
 
GDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App EngineGDG Addis - An Introduction to Django and App Engine
GDG Addis - An Introduction to Django and App Engine
 
Drupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp BratislavaDrupal Security from Drupalcamp Bratislava
Drupal Security from Drupalcamp Bratislava
 
ITB2017 - Keynote
ITB2017 - KeynoteITB2017 - Keynote
ITB2017 - Keynote
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO Devs
 
Magento performance feat. core Hacks
Magento performance feat. core HacksMagento performance feat. core Hacks
Magento performance feat. core Hacks
 
Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8
 
The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)The Solar Framework for PHP 5 (2010 Confoo)
The Solar Framework for PHP 5 (2010 Confoo)
 
Rapid Application Development with CakePHP 1.3
Rapid Application Development with CakePHP 1.3Rapid Application Development with CakePHP 1.3
Rapid Application Development with CakePHP 1.3
 
Blue Green Sitecore Deployments on Azure
Blue Green Sitecore Deployments on AzureBlue Green Sitecore Deployments on Azure
Blue Green Sitecore Deployments on Azure
 
Creating Custom Templates for Joomla! 2.5
Creating Custom Templates for Joomla! 2.5Creating Custom Templates for Joomla! 2.5
Creating Custom Templates for Joomla! 2.5
 
Drupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First StepsDrupal Camp Porto - Developing with Drupal: First Steps
Drupal Camp Porto - Developing with Drupal: First Steps
 
Reactive summit 2020 microsoft orleans the easy way
Reactive summit 2020   microsoft orleans the easy wayReactive summit 2020   microsoft orleans the easy way
Reactive summit 2020 microsoft orleans the easy way
 

More from Philip Norton

Webform and Drupal 8
Webform and Drupal 8Webform and Drupal 8
Webform and Drupal 8Philip Norton
 
Acquia Drupal Certification
Acquia Drupal CertificationAcquia Drupal Certification
Acquia Drupal CertificationPhilip Norton
 
Drupal Performance : DrupalCamp North
Drupal Performance : DrupalCamp NorthDrupal Performance : DrupalCamp North
Drupal Performance : DrupalCamp NorthPhilip Norton
 
Getting Started With Jenkins And Drupal
Getting Started With Jenkins And DrupalGetting Started With Jenkins And Drupal
Getting Started With Jenkins And DrupalPhilip Norton
 
Making The Drupal Pill Easier To Swallow
Making The Drupal Pill Easier To SwallowMaking The Drupal Pill Easier To Swallow
Making The Drupal Pill Easier To SwallowPhilip Norton
 

More from Philip Norton (9)

ReactPHP
ReactPHPReactPHP
ReactPHP
 
Webform and Drupal 8
Webform and Drupal 8Webform and Drupal 8
Webform and Drupal 8
 
Acquia Drupal Certification
Acquia Drupal CertificationAcquia Drupal Certification
Acquia Drupal Certification
 
Drupal Performance : DrupalCamp North
Drupal Performance : DrupalCamp NorthDrupal Performance : DrupalCamp North
Drupal Performance : DrupalCamp North
 
Getting Started With Jenkins And Drupal
Getting Started With Jenkins And DrupalGetting Started With Jenkins And Drupal
Getting Started With Jenkins And Drupal
 
Drupal theming
Drupal themingDrupal theming
Drupal theming
 
Drush
DrushDrush
Drush
 
Making The Drupal Pill Easier To Swallow
Making The Drupal Pill Easier To SwallowMaking The Drupal Pill Easier To Swallow
Making The Drupal Pill Easier To Swallow
 
Drupal 7 Queues
Drupal 7 QueuesDrupal 7 Queues
Drupal 7 Queues
 

Recently uploaded

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 

Recently uploaded (20)

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 

Drupal 8 Configuration Management

  • 1. Drupal 8 Configuration Management Phil Norton Drupal Camp Yorkshire 2014 DrupalCamp Yorkshire 2014
  • 2. Me • Phil Norton (@philipnorton42) • #! code (www.hashbangcode.com) • Technical Lead at Access • Help run NWDUG
  • 12. User
  • 13. Contents of a block
  • 14. Configuration Content Blog Post ! Taxonomy Term ! Menu Item ! Block Content Permissions ! Field Definition ! Vocabulary ! Menu ! Variable TAC ! Webform ! Default Content ! Views
  • 15. Configuration Content Blog Post ! Taxonomy Term ! Menu Item ! Block Content Permissions ! Field Definition ! Vocabulary ! Menu ! Variable TAC ! Webform ! Default Content ! Views
  • 16. Content ! ! Session ! ! State ! ! Configuration An article page, uploaded files Logged in status, shopping carts Last cron run Everything else
  • 17. Challenge • Developer: • Wants to work on code • Wants to change the config • Wants to deploy across environments • Client: • Wants to work on content • Doesn’t want to lose work
  • 19. Drupal 7 Configuration • Features • Install/Update hooks • Install Profiles How do we currently manage configuration in Drupal?
  • 20. Features • Export and import of certain configurations as modules • Not all modules supported so there tends to be gaps in the configuration • Adding Features support for modules is not easy • Features ‘Overridden’ sadness
  • 21. Install/Update Hooks • Create tables • Set up variables • Fill in ‘gaps’ in Features modules
  • 22. Install Profiles • Combine Features modules and install hooks • Full site setup out of the box • Limited Drupal API available • Doesn’t always work as planned
  • 24. Drupal 8 Initiatives • Configuration Management • Web Services • Multilingual • HTML 5 • Mobile
  • 26. CMI • Lead by Greg Dunlap - (heyrocker) Also involved are: • Joel Farris (senpai) • Jonathan Lambert (jlambert) • David Strauss (davidstrauss) • Larry Garfield (crell) • Karoly Negeyesi (chx) • Angie Byron (webchick) • Alex Pott (alexpott) • And many others…
  • 27. CMI To build Drupal from the ground up to be better at configuration management
  • 28. CMI • Move configuration management into core • Allow storage of configuration in files • Allow the transfer of configuration between environments • Create an API to allow custom configurations • Integrate UUID into core so certain configurations can be given machine names
  • 29. Usage
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45. Behind The Scenes • Active configuration is stored in the database • Clicking Export collates the configuration that each module defines and combines it with the current active configuration • Export contains the active configuration in the form of YAML files
  • 46. Behind The Scenes • YAML files are used to store the configuration • A ‘staging’ and an ‘active’ directory are defined in settings.php • Used to store and compare the current configuration • By default the directories are stored in the location
 /sites/default/files/config_<hash>/
  • 47.
  • 48. active • Originally intended to be used as the location of the active configuration • Active configuration is now stored in the database • Configuration development module (https:// drupal.org/project/config_devel)
  • 49. staging • Stores current imported configuration as YAML files • Shows difference between configuration changes • Changes made here can be imported into active configuration
  • 50. YAML! YAML Ain't Markup Language ! (Yet Another Markup Language)
  • 51. YAML • Data orientated format • Has several benefits over other formats like INI, JSON, XML • Support for hierarchical values • Lists and associative arrays possible • Used extensively in Drupal 8
  • 52. YAML • Simple values defined by key: value • Hierarchical values defined with whitespace keys: key1: value key2: value
  • 53. YAML Comments start the line with a ‘#’ ! # This is a comment item: value
  • 54. YAML Lists ! - item1 - item2 - item3 ! ! [item1, item2, item3] ! ! - {name: 'webserver1', ip: ‘192.168.100.100’} - {name: 'webserver2', ip: ‘192.168.100.101’} - {name: 'webserver3', ip: ‘192.168.100.102’}
  • 55. uuid: '' name: Drupal mail: '' slogan: '' page: 403: '' 404: '' front: user admin_compact_mode: false weight_select_max: 100 langcode: en core/modules/system/config/install/system.site.yml
  • 56. YAML Filenames In Drupal 8 • < module >.< component >.yml
 
 system.settings.yml
 views.settings.yml • < module >.< component >.< entity >.yml
 
 image.style.medium.yml
 views.view.content.yml
  • 58. Configuration Schema • Needed to define what your configuration will hold • Kwalify inspired format • Used to define what types of data the configuration will contain • See more at: https://drupal.org/node/1905070
  • 59. system.schema.yml system.site: type: mapping label: 'Site information' mapping: uuid: type: string label: 'Site UUID' name: type: label label: 'Site name' mail: type: email label: 'E-mail address' slogan: type: label label: 'Slogan' page: type: mapping label: 'Pages' mapping: 403: type: path label: 'Default 403 (access denied) page' 404: type: path label: 'Default 404 (not found) page' front: type: path label: 'Default front page' admin_compact_mode: type: boolean label: 'Compact mode' weight_select_max: type: integer label: 'Weight element maximum value' langcode: type: string label: 'Default language'
  • 60. system.schema.yml system.site: type: mapping label: 'Site information' mapping: uuid: type: string label: 'Site UUID' name: type: label label: 'Site name' Schema name Also shows the configuration filename “system.site.yml” Used to reference this configuration
  • 61. system.schema.yml system.site: type: mapping label: 'Site information' mapping: uuid: type: string label: 'Site UUID' name: type: label label: 'Site name' Container data type ‘mapping’ is for key value sets allows for associative arrays of different data types
  • 62. system.schema.yml system.site: type: mapping label: 'Site information' mapping: uuid: type: string label: 'Site UUID' name: type: label label: 'Site name' Label Used as an interface label
  • 63. system.schema.yml system.site: type: mapping label: 'Site information' mapping: uuid: type: string label: 'Site UUID' name: type: label label: 'Site name' Start of mapping section item key item type item label
  • 64. Simple Configuration • Can be single values or arrays of values • Used to store global configuration options • Easy to implement: • Create schema YAML file in 
 < module >/config/install/schema • Create config YAML file 
 < module >/config/install
  • 65. Getting Configuration uuid: '' name: Drupal mail: '' slogan: '' page: 403: '' 404: '' front: user admin_compact_mode: false weight_select_max: 100 langcode: en ! ! $config = Drupal::config('system.site');
 $email = $config->get('mail');
 ! $cofig = Drupal::config(‘system.site') $page403 = $config->get('page.403');
 

  • 66. Getting Configuration uuid: '' name: Drupal mail: '' slogan: '' page: 403: '' 404: '' front: user admin_compact_mode: false weight_select_max: 100 langcode: en ! ! $email = Drupal::config('system.site')->get('mail');
 ! $page403 = Drupal::config('system.site')->get('page.403');
 
 !
  • 67. Setting Configuration $config = Drupal::config('system.site');
 $config->set(‘mail’, ‘test@example.com’);
 $config->save();
 ! ! $config = Drupal::config(‘system.site’)->set('mail', ‘test@example.com’);
 $config->save(); ! ! 
 Drupal::config(‘system.site’)->set('mail', ‘test@example.com)- >save();
  • 68. Clear Configuration $config = Drupal::config('system.site'); $config->clear('mail')->save();
 
 
 ! Drupal::config('system.site')->delete();
  • 69. Configuration Entities • Used to store custom entity configurations • More complex and therefore harder to implement • Used for configurations that have multiple entries
 Example: Views, Image cache settings, Contact form categories
  • 70. Contact Category Interface namespace Drupalcontact; ! use DrupalCoreConfigEntityConfigEntityInterface; ! /** * Provides an interface defining a contact category entity. */ interface CategoryInterface extends ConfigEntityInterface { ! }
  • 71. Contact Category Entity namespace DrupalcontactEntity; ! use DrupalCoreConfigEntityConfigEntityBase; use DrupalCoreEntityEntityStorageInterface; use DrupalcontactCategoryInterface; ! /** * Defines the contact category entity. * * @ConfigEntityType( * id = "contact_category", * label = @Translation("Contact category"), * controllers = { * "access" = "DrupalcontactCategoryAccessController", * "list_builder" = "DrupalcontactCategoryListBuilder", * "form" = { * "add" = "DrupalcontactCategoryForm", * "edit" = "DrupalcontactCategoryForm", * "delete" = "DrupalcontactFormCategoryDeleteForm" * } * }, * config_prefix = "category", * admin_permission = "administer contact forms", * bundle_of = "contact_message", * entity_keys = { * "id" = "id", * "label" = "label" * }, * links = { * "delete-form" = "contact.category_delete", * "edit-form" = "contact.category_edit" * } * ) */ class Category extends ConfigEntityBase implements CategoryInterface {
  • 72. class Category extends ConfigEntityBase implements CategoryInterface { ! /** * The category ID. * * @var string */ public $id; ! /** * The category label. * * @var string */ public $label; ! /** * List of recipient e-mail addresses. * * @var array */ public $recipients = array(); ! /** * An auto-reply message to send to the message author. * * @var string */ public $reply = ''; ! /** * Weight of this category (used for sorting). * * @var int */ public $weight = 0;
  • 73. contact.category.personal.yml id: personal label: 'Personal contact form' recipients: { } reply: '' weight: 0 status: true uuid: 43155e41-8a58-4264-ab00-be97a0736aa0 langcode: en dependencies: { } ! ! $contact_category = $this->entityManager() ->getStorage('contact_category') ->load('personal'); ! $contact_category->label();
  • 74. contact.category.personal.yml id: personal label: 'Personal contact form' recipients: { } reply: '' weight: 0 status: true uuid: 43155e41-8a58-4264-ab00-be97a0736aa0 langcode: en dependencies: { } ! ! $config = Drupal::config('contact.category.personal')->get(); $label = $config['label']; ! $label = Drupal::config(‘contact.category.personal')->get('label');
  • 75. Drush • Full Drush integration available • Need Drush version 7.x • Currently in dev branch of Drush • List of Drush commands:
 http://www.drushcommands.com/drush-7x/config/ config-list
  • 76. Drush Export config from the active configuration to the staging directory
 
 drush config-export
 
 drush cex
  • 77. Drush Import the staging configuration into the active configuration
 
 drush config-import
 
 drush cim
  • 78. Workflow • Staging config should become part of your codebase • New configuration changes should be exported and integrated into code base • Configuration in code should then be used to move configuration between servers
  • 79. Dev Stage Live export deploy deploy import import Git Config Code Git Config Code Git Config Code Workflow
  • 80. Dev Stage Live drush cex deploy deploy drush cim drush cim Git Config Code Git Config Code Git Config Code Drush Workflow
  • 81. Roll Your Own Configurations ! ! ! ! Create a module that stores simple configurations
  • 82. MyModule • A module that integrates with the configuration management API • Defines a single configuration item • Defines a page to display the configuration • Defines a form to change the configuration
  • 83. MyModule Configuration • mymodule.info.yml file defines the module • mymodule.settings.yml contains the module configuration • mymodule.schema.yml contains information about the configuration item being defined • mymodule.routing.yml defines routes to a page and a form
  • 84. name: 'MyModule' type: module description: 'My module' version: VERSION core: 8.x mymodule.info.yml
  • 86. mymodule.settings: type: mapping label: 'My Module Settings' mapping: configitem: type: string label: 'A config item' /config/schema/mymodule.schema.yml
  • 87. mymodule.page: path: '/mymodule' defaults: _content: 'DrupalmymoduleController MyModuleController::description' requirements: _access: 'TRUE' ! mymodule.admin: path: '/mymodule/edit' defaults: _form: 'DrupalmymoduleFormMyModuleAdminForm' requirements: _access: 'TRUE' mymodule.routing.yml
  • 88. MyModule Page • mymodule.routing.yml defines the route to the page • Destination MyModuleController::description() loads the configuration and displays it
  • 89. namespace DrupalmymoduleController; ! use DrupalCoreControllerControllerBase; ! /** * Custom page. */ class MyModuleController extends ControllerBase { ! /** * An example page. * * @return string * A render array containing some page content. */ public function description() { ! $mymodule_config = Drupal::config('mymodule.settings'); ! $output = array(); ! $output['mymodule_output'] = array( '#markup' => t('The value of configitem is "!configitem"', array('!configitem' => $mymodule_config->get('configitem'))) ); ! return $output; } } lib/Drupal/mymodule/Controller/MyModuleController.php
  • 90. MyModule Form • mymodule.routing.yml defines the route to the form • Class MyModuleAdminForm defines a form that loads the configuration • Configuration is saved upon submission of the form
  • 91. namespace DrupalmymoduleForm; ! use DrupalCoreFormConfigFormBase; ! /** * Configure MyModule admin settings for this site. */ class MyModuleAdminForm extends ConfigFormBase { ! /** * Implements DrupalCoreFormFormInterface::getFormID(). */ public function getFormID() { return 'mymodule_edit_form'; } ! /** * Implements DrupalCoreFormFormInterface::buildForm(). */ public function buildForm(array $form, array &$form_state) { $config = $this->configFactory()->get('mymodule.settings'); ! $form['configitem'] = array( '#type' => 'textfield', '#title' => t('Config Settings'), '#default_value' => $config->get('configitem') ); ! return parent::buildForm($form, $form_state); } ! /** * Implements DrupalCoreFormFormInterface::submitForm(). */ public function submitForm(array &$form, array &$form_state) { $config = $this->configFactory()->get('mymodule.settings'); ! $config->set('configitem', $form_state['values']['configitem'])->save(); ! parent::submitForm($form, $form_state); } } lib/Drupal/mymodule/Form/MyModuleAdminForm.php
  • 92. ! /** * Implements DrupalCoreFormFormInterface::buildForm(). */ public function buildForm(array $form, array &$form_state) { $config = $this->configFactory()->get('mymodule.settings'); ! $form['configitem'] = array( '#type' => 'textfield', '#title' => t('Config Settings'), '#default_value' => $config->get('configitem') ); ! return parent::buildForm($form, $form_state); } lib/Drupal/mymodule/Form/MyModuleAdminForm.php
  • 93. ! ! /** * Implements DrupalCoreFormFormInterface::submitForm(). */ public function submitForm(array &$form, array &$form_state) { $config = $this->configFactory()->get('mymodule.settings'); ! $config->set('configitem', $form_state['values']['configitem'])->save(); ! parent::submitForm($form, $form_state); } lib/Drupal/mymodule/Form/MyModuleAdminForm.php
  • 94.
  • 96. Drupal 7 • Configuration management has been back ported into Drupal 7 • Configuration Management module 
 https://drupal.org/project/configuration
  • 97. Resources • Creating Drupal 8.x modules
 https://drupal.org/developing/modules/8 ! • Configuration API in Drupal 8
 https://drupal.org/node/1667894 ! • Understanding Drupal 8's config entities
 http://www.previousnext.com.au/blog/understanding-drupal-8s-config-entities ! • Configuration schema/metadata
 https://drupal.org/node/1905070 ! • Configuration inspector for Drupal 8
 https://drupal.org/project/config_inspector
  • 98. Drupal 8 CMI Needs You! • Lots of work still needs to be done on CMI • Go to http://drupal8cmi.org/ and pick an issue to work on
  • 99. Me • Phil Norton (@philipnorton42) • #! code (www.hashbangcode.com) • Technical Lead at Access • Help run NWDUG