SlideShare a Scribd company logo
1 of 42
EXPLORING COMPOSER IN DRUPAL 8
WITH DRUPAL-PROJECT
Salvador Molina
#DrupalCampEs
www.adevfromtheplains.com
Original talk by @isholgueras
Greetings!
I am Salva Molina
● Drupal Developer @ Bluespark.
● Slv_ /”self”/ in drupal.org.
● @Salva_bg on Twitter.
● https://github.com/salvamomo/.
● Rants, cries and nonsense at http://adevfromtheplains.com.
Let’s talk about
Composer
1. Composer basics.
1. Drupal-project.
1. Wrapping up.
Composer basics
- What is it?
- Main Commands
What is Composer?
● Dependency Manager.
● Not a Package Manager.
● Inspired by node’s npm and Ruby’s bundler.
composer.json
{
"name": "my-vendor/my-project",
"require": {
"monolog/monolog": "1.0.*",
"consolidation/robo": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.8"
},
"minimum-stability": "dev",
"prefer-stable": true,
}
composer.lock
{
"name": "consolidation/robo",
"version": "1.0.5",
"source": {
"type": "git",
"url": "https://github.com/consolidation/Robo.git",
"reference": "1f1d92807f72901e049e9df048b412c3bc3652c9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/consolidation/Robo/zipball/d064",
"Reference": "1f1d92807f72901e049e9df048b412c3bc3652c9",
},
Installing Composer
● Global is better
curl -sS https://getcomposer.org/installer | sudo php -- --
install-dir=/usr/local/bin --filename=composer
Main commands
▷ composer init
Main commands
▷ composer init
▷ composer install
1
2
3
Main commands
▷ composer init
▷ composer install
▷ composer update
1
2
3
Main commands
▷ composer init
▷ composer install
▷ composer update
▷ composer require
Vendor and autoload.php
Autoload.php
Has all registered classes and namespaces.
/vendor
Directory where libraries are stored.
<?php
// File: ./app.php
require_once “./vendor/autoload.php”
What is Autoload.php for?
DependenciesAutoload.phpCustom code
Drupal-project
- What is Drupal-project?
- Daily management
- Under the hood
Drupal Composer
Working group for making Drupal work with Composer:
http://drupal-composer.org
Composer template for Drupal Projects:
https://github.com/drupal-composer/drupal-project
Drupal Project
What does the template do?
● Installs Drupal in the web directory.
● Alters Drupal’s default autoloader to point at the one
generated by composer, in the project root.
What does the template do?
Modules (packages of type drupal-module) will be placed in
web/modules/contrib/
Themes (packages of type drupal-theme) will be placed in
web/themes/contrib/
Profiles (packages of type drupal-profile) will be placed in
web/profiles/contrib/
What does the template do?
Creates default writable versions of settings.php and
services.yml.
Creates sites/default/files-directory.
Latest version of drush is installed locally for use at
vendor/bin/drush.
Latest version of DrupalConsole is installed locally for use at
vendor/bin/drupal.
In one command
composer create-project 
drupal-composer/drupal-project:8.x-dev 
my-project-dir 
--stability dev 
--no-interaction
my-project-dir
├── .gitignore
├── composer.json
├── composer.lock
├── config
├── drush
├── LICENSE
├── phpunit.xml.dist
├── README.md
├── scripts
├── vendor
└── web
Daily management
The bread and butter of Drupal with drupal-project
Starting from scratch
> ~ $ git clone https://git/repo.git
> ~ $ cd repo
> ~/repo $ composer install
> ~/repo $ cd web
> ~/repo/web $ drush site-install profile ...
Managing contrib
Download, delete or update modules, themes or
profiles:> ~/repo $ composer require drupal/ds
> ~/repo $ composer remove drupal/ds
> ~/repo $ composer update drupal/ds*
> ~/repo/web $ drush ...
Managing core
Clean repo (git stash)
> ~/repo $ composer update drupal/core 
--with-dependencies
> ~/repo $ git diff
Managing core
If there are no conflicts:
> ~/repo/web $ drush updb
> ~/repo $ git commit -am “Updated core”
Managing core
If there are:
Create a branch.
Fix conflicts (.htaccess, robots.txt,...).
Merge to master (1 commit if possible).
Done!
Applying patches
composer.json:
"extra": {
"patches": {
"drupal/ds": {
"Patch description #2334434": "URL to patch"
}
}
}
Under the hood
Drupal-scaffold
Part of the “scripts” attribute in composer.json
Downloads files (index.php, update.php, etc...)
Create new ones from templates
default.settings.php -> settings.php
Drush policy
Avoid execution of drush pm-update
Alter drush-aliases
Avoid writing in @prod *
*Needs to be added: https://github.com/drush-ops/drush/blob/8.x/examples/policy.drush.inc
Drush policy
Naughty developers...
Problems following workflow...
Grab them by the policy.
Drush policy
Wrapping up
Pros
Amazing dependency management.
All contrib out of git.
Composer hooks (pre, post, …).
Standardized.
Patches.
Also for D7.
Cons
Much more strict than the “classical way”
Another point of failure, composer.
If github is down…
If packagist is down…
If your internet is slow...
Do we commit “vendor/”?
Software distribution VS software deployment.
Robustness of deployments.
Git history.
Git size.
Best practices.
Code auditing.
Does one size fit all?
To git...
Robustness in deployments.
Easier and more straightforward
deployments.
Proper auditing of all production code.
Clear, accessible history of code
changes.
Small amount of extra work (once) to
ensure right process for every possible
library.
Unneeded complexity increase in
deployments, with more chance for
builds to break due to external
systems.
No auditing of code changes.
A bit smaller code repository.
Or not to git?
Any questions?
SPAM
#OPHPEN_READS
A #PHP reading club in Spanish.
http://www.isholgueras.com/blog/ophpenreads-iniciamos-el-club-de-lectura-de-libros-tecnicos
https://www.youtube.com/playlist?list=PL3NN5-oQnuvrkvOrdn1hzOHIlQOe7Gk5k
¡Gracias!
Thank you!
Twitter: @Salva_bg
Blog: http://adevfromtheplains.com
#DrupalCampEs

More Related Content

What's hot

Drush deploy presentation by Goruachev Mikhail
Drush deploy presentation by Goruachev MikhailDrush deploy presentation by Goruachev Mikhail
Drush deploy presentation by Goruachev MikhailLemberg Solutions
 
Drush for humans - SANDcamp 2013
Drush for humans - SANDcamp 2013Drush for humans - SANDcamp 2013
Drush for humans - SANDcamp 2013Jon Peck
 
Improving your Drupal 8 development workflow DrupalCampLA
Improving your Drupal 8 development workflow DrupalCampLAImproving your Drupal 8 development workflow DrupalCampLA
Improving your Drupal 8 development workflow DrupalCampLAJesus Manuel Olivas
 
[drupalday2017] - Devel - D8 release party
[drupalday2017] - Devel - D8 release party[drupalday2017] - Devel - D8 release party
[drupalday2017] - Devel - D8 release partyDrupalDay
 
drush - the commandline is your friend
drush - the commandline is your frienddrush - the commandline is your friend
drush - the commandline is your friendNathan Lisgo
 
Angularjs Workshop Pre-Requisites
Angularjs Workshop Pre-Requisites Angularjs Workshop Pre-Requisites
Angularjs Workshop Pre-Requisites Houssem Yahiaoui
 
Drush and drupal. администрирование волчек михаил
Drush and drupal. администрирование  волчек михаилDrush and drupal. администрирование  волчек михаил
Drush and drupal. администрирование волчек михаилdrupalconf
 
Drupal Developer Days Keynote
Drupal Developer Days KeynoteDrupal Developer Days Keynote
Drupal Developer Days KeynoteAngela Byron
 
Drush&drupal. administration
Drush&drupal. administrationDrush&drupal. administration
Drush&drupal. administrationzabej
 
Wordpress development: A Modern Approach
Wordpress development:  A Modern ApproachWordpress development:  A Modern Approach
Wordpress development: A Modern ApproachAlessandro Fiore
 
Debian packaging howto
Debian packaging howtoDebian packaging howto
Debian packaging howtoDing Zhou
 
Drush und Multisite: drush_multi
Drush und Multisite: drush_multiDrush und Multisite: drush_multi
Drush und Multisite: drush_multiFlorian Latzel
 
drush_multi @ DrupalDevDays 2010
drush_multi @ DrupalDevDays 2010drush_multi @ DrupalDevDays 2010
drush_multi @ DrupalDevDays 2010Florian Latzel
 
Grunt understanding
Grunt understandingGrunt understanding
Grunt understandingKhalid Khan
 
Open Build Service 道場―パッケージの新規作成編
Open Build Service 道場―パッケージの新規作成編Open Build Service 道場―パッケージの新規作成編
Open Build Service 道場―パッケージの新規作成編Fuminobu Takeyama
 
Installing OpenCV 4 on Ubuntu 18.x
Installing OpenCV 4 on Ubuntu 18.xInstalling OpenCV 4 on Ubuntu 18.x
Installing OpenCV 4 on Ubuntu 18.xNader Karimi
 
Improving Workflows With Grunt.js - Big D Design 2014 - Dallas Texas
Improving Workflows With Grunt.js - Big D Design 2014 - Dallas TexasImproving Workflows With Grunt.js - Big D Design 2014 - Dallas Texas
Improving Workflows With Grunt.js - Big D Design 2014 - Dallas TexasPreston McCauley
 

What's hot (20)

Drupal 101 V-0.1
Drupal 101 V-0.1Drupal 101 V-0.1
Drupal 101 V-0.1
 
Drush deploy presentation by Goruachev Mikhail
Drush deploy presentation by Goruachev MikhailDrush deploy presentation by Goruachev Mikhail
Drush deploy presentation by Goruachev Mikhail
 
Drush
DrushDrush
Drush
 
Drush for humans - SANDcamp 2013
Drush for humans - SANDcamp 2013Drush for humans - SANDcamp 2013
Drush for humans - SANDcamp 2013
 
Improving your Drupal 8 development workflow DrupalCampLA
Improving your Drupal 8 development workflow DrupalCampLAImproving your Drupal 8 development workflow DrupalCampLA
Improving your Drupal 8 development workflow DrupalCampLA
 
[drupalday2017] - Devel - D8 release party
[drupalday2017] - Devel - D8 release party[drupalday2017] - Devel - D8 release party
[drupalday2017] - Devel - D8 release party
 
drush - the commandline is your friend
drush - the commandline is your frienddrush - the commandline is your friend
drush - the commandline is your friend
 
Angularjs Workshop Pre-Requisites
Angularjs Workshop Pre-Requisites Angularjs Workshop Pre-Requisites
Angularjs Workshop Pre-Requisites
 
Drush and drupal. администрирование волчек михаил
Drush and drupal. администрирование  волчек михаилDrush and drupal. администрирование  волчек михаил
Drush and drupal. администрирование волчек михаил
 
Drupal Developer Days Keynote
Drupal Developer Days KeynoteDrupal Developer Days Keynote
Drupal Developer Days Keynote
 
Drush&drupal. administration
Drush&drupal. administrationDrush&drupal. administration
Drush&drupal. administration
 
Wordpress development: A Modern Approach
Wordpress development:  A Modern ApproachWordpress development:  A Modern Approach
Wordpress development: A Modern Approach
 
Debian packaging howto
Debian packaging howtoDebian packaging howto
Debian packaging howto
 
Drush und Multisite: drush_multi
Drush und Multisite: drush_multiDrush und Multisite: drush_multi
Drush und Multisite: drush_multi
 
Dockerandjenkins citz2014
Dockerandjenkins citz2014Dockerandjenkins citz2014
Dockerandjenkins citz2014
 
drush_multi @ DrupalDevDays 2010
drush_multi @ DrupalDevDays 2010drush_multi @ DrupalDevDays 2010
drush_multi @ DrupalDevDays 2010
 
Grunt understanding
Grunt understandingGrunt understanding
Grunt understanding
 
Open Build Service 道場―パッケージの新規作成編
Open Build Service 道場―パッケージの新規作成編Open Build Service 道場―パッケージの新規作成編
Open Build Service 道場―パッケージの新規作成編
 
Installing OpenCV 4 on Ubuntu 18.x
Installing OpenCV 4 on Ubuntu 18.xInstalling OpenCV 4 on Ubuntu 18.x
Installing OpenCV 4 on Ubuntu 18.x
 
Improving Workflows With Grunt.js - Big D Design 2014 - Dallas Texas
Improving Workflows With Grunt.js - Big D Design 2014 - Dallas TexasImproving Workflows With Grunt.js - Big D Design 2014 - Dallas Texas
Improving Workflows With Grunt.js - Big D Design 2014 - Dallas Texas
 

Similar to Exploring composer in drupal 8 with drupal project - salva molina

Using Composer with Drupal and Drush
Using Composer with Drupal and DrushUsing Composer with Drupal and Drush
Using Composer with Drupal and DrushPantheon
 
Composer tools and frameworks for Drupal
Composer tools and frameworks for DrupalComposer tools and frameworks for Drupal
Composer tools and frameworks for DrupalPromet Source
 
Composer tools and frameworks for drupal.ppt
Composer tools and frameworks for drupal.pptComposer tools and frameworks for drupal.ppt
Composer tools and frameworks for drupal.pptPromet Source
 
Composer Tools & Frameworks for Drupal
Composer Tools & Frameworks for DrupalComposer Tools & Frameworks for Drupal
Composer Tools & Frameworks for DrupalPantheon
 
Composer JSON kills make files
Composer JSON kills make filesComposer JSON kills make files
Composer JSON kills make filesropsu
 
Drush in the Composer Era
Drush in the Composer EraDrush in the Composer Era
Drush in the Composer EraPantheon
 
Lean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and DrushLean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and DrushPantheon
 
Introduction to Composer for Drupal
Introduction to Composer for DrupalIntroduction to Composer for Drupal
Introduction to Composer for DrupalLuc Bézier
 
Composer is the new Drush - Drupal Developer Training (internal)
Composer is the new Drush - Drupal Developer Training (internal)Composer is the new Drush - Drupal Developer Training (internal)
Composer is the new Drush - Drupal Developer Training (internal)Exove
 
Managing your Drupal project with Composer
Managing your Drupal project with ComposerManaging your Drupal project with Composer
Managing your Drupal project with ComposerMatt Glaman
 
Composer & Drupal
Composer & DrupalComposer & Drupal
Composer & Drupaldrubb
 
Docman - The swiss army knife for Drupal multisite docroot management and dep...
Docman - The swiss army knife for Drupal multisite docroot management and dep...Docman - The swiss army knife for Drupal multisite docroot management and dep...
Docman - The swiss army knife for Drupal multisite docroot management and dep...Aleksey Tkachenko
 
Face your fears: Drush and Aegir
Face your fears: Drush and AegirFace your fears: Drush and Aegir
Face your fears: Drush and AegirIztok Smolic
 
Drupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflowDrupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflowvaluebound
 
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and BeyondDrupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and BeyondDrupalDay
 
5 Important Tools for Drupal Development
5 Important Tools for Drupal Development5 Important Tools for Drupal Development
5 Important Tools for Drupal Developmentjcarrig
 
Introduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, TerminologiesIntroduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, TerminologiesGerald Villorente
 
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011camp_drupal_ua
 
Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011
Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011
Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011Vlad Savitsky
 

Similar to Exploring composer in drupal 8 with drupal project - salva molina (20)

Using Composer with Drupal and Drush
Using Composer with Drupal and DrushUsing Composer with Drupal and Drush
Using Composer with Drupal and Drush
 
Composer tools and frameworks for Drupal
Composer tools and frameworks for DrupalComposer tools and frameworks for Drupal
Composer tools and frameworks for Drupal
 
Composer tools and frameworks for drupal.ppt
Composer tools and frameworks for drupal.pptComposer tools and frameworks for drupal.ppt
Composer tools and frameworks for drupal.ppt
 
Composer Tools & Frameworks for Drupal
Composer Tools & Frameworks for DrupalComposer Tools & Frameworks for Drupal
Composer Tools & Frameworks for Drupal
 
Composer JSON kills make files
Composer JSON kills make filesComposer JSON kills make files
Composer JSON kills make files
 
Drush in the Composer Era
Drush in the Composer EraDrush in the Composer Era
Drush in the Composer Era
 
Lean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and DrushLean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and Drush
 
Introduction to Composer for Drupal
Introduction to Composer for DrupalIntroduction to Composer for Drupal
Introduction to Composer for Drupal
 
Composer is the new Drush - Drupal Developer Training (internal)
Composer is the new Drush - Drupal Developer Training (internal)Composer is the new Drush - Drupal Developer Training (internal)
Composer is the new Drush - Drupal Developer Training (internal)
 
Managing your Drupal project with Composer
Managing your Drupal project with ComposerManaging your Drupal project with Composer
Managing your Drupal project with Composer
 
Composer & Drupal
Composer & DrupalComposer & Drupal
Composer & Drupal
 
Docman - The swiss army knife for Drupal multisite docroot management and dep...
Docman - The swiss army knife for Drupal multisite docroot management and dep...Docman - The swiss army knife for Drupal multisite docroot management and dep...
Docman - The swiss army knife for Drupal multisite docroot management and dep...
 
Face your fears: Drush and Aegir
Face your fears: Drush and AegirFace your fears: Drush and Aegir
Face your fears: Drush and Aegir
 
Drupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflowDrupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflow
 
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and BeyondDrupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
 
5 Important Tools for Drupal Development
5 Important Tools for Drupal Development5 Important Tools for Drupal Development
5 Important Tools for Drupal Development
 
Introduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, TerminologiesIntroduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, Terminologies
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
 
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011
Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011
 
Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011
Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011
Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011
 

Recently uploaded

Operating System chapter 9 (Virtual Memory)
Operating System chapter 9 (Virtual Memory)Operating System chapter 9 (Virtual Memory)
Operating System chapter 9 (Virtual Memory)NareenAsad
 
Lab Manual Arduino UNO Microcontrollar.docx
Lab Manual Arduino UNO Microcontrollar.docxLab Manual Arduino UNO Microcontrollar.docx
Lab Manual Arduino UNO Microcontrollar.docxRashidFaridChishti
 
Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...
Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...
Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...Nitin Sonavane
 
Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...IJECEIAES
 
CLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference ModalCLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference ModalSwarnaSLcse
 
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024EMMANUELLEFRANCEHELI
 
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...Amil baba
 
Basics of Relay for Engineering Students
Basics of Relay for Engineering StudentsBasics of Relay for Engineering Students
Basics of Relay for Engineering Studentskannan348865
 
Autodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptxAutodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptxMustafa Ahmed
 
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdflitvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdfAlexander Litvinenko
 
Research Methodolgy & Intellectual Property Rights Series 2
Research Methodolgy & Intellectual Property Rights Series 2Research Methodolgy & Intellectual Property Rights Series 2
Research Methodolgy & Intellectual Property Rights Series 2T.D. Shashikala
 
Piping and instrumentation diagram p.pdf
Piping and instrumentation diagram p.pdfPiping and instrumentation diagram p.pdf
Piping and instrumentation diagram p.pdfAshrafRagab14
 
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas SachpazisSeismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas SachpazisDr.Costas Sachpazis
 
AI in Healthcare Innovative use cases and applications.pdf
AI in Healthcare Innovative use cases and applications.pdfAI in Healthcare Innovative use cases and applications.pdf
AI in Healthcare Innovative use cases and applications.pdfmahaffeycheryld
 
ALCOHOL PRODUCTION- Beer Brewing Process.pdf
ALCOHOL PRODUCTION- Beer Brewing Process.pdfALCOHOL PRODUCTION- Beer Brewing Process.pdf
ALCOHOL PRODUCTION- Beer Brewing Process.pdfMadan Karki
 
Artificial Intelligence in due diligence
Artificial Intelligence in due diligenceArtificial Intelligence in due diligence
Artificial Intelligence in due diligencemahaffeycheryld
 
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfInstruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfEr.Sonali Nasikkar
 
Passive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.pptPassive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.pptamrabdallah9
 
Final DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualFinal DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualBalamuruganV28
 
Raashid final report on Embedded Systems
Raashid final report on Embedded SystemsRaashid final report on Embedded Systems
Raashid final report on Embedded SystemsRaashidFaiyazSheikh
 

Recently uploaded (20)

Operating System chapter 9 (Virtual Memory)
Operating System chapter 9 (Virtual Memory)Operating System chapter 9 (Virtual Memory)
Operating System chapter 9 (Virtual Memory)
 
Lab Manual Arduino UNO Microcontrollar.docx
Lab Manual Arduino UNO Microcontrollar.docxLab Manual Arduino UNO Microcontrollar.docx
Lab Manual Arduino UNO Microcontrollar.docx
 
Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...
Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...
Module-III Varried Flow.pptx GVF Definition, Water Surface Profile Dynamic Eq...
 
Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...
 
CLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference ModalCLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference Modal
 
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
 
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
 
Basics of Relay for Engineering Students
Basics of Relay for Engineering StudentsBasics of Relay for Engineering Students
Basics of Relay for Engineering Students
 
Autodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptxAutodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptx
 
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdflitvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
litvinenko_Henry_Intrusion_Hong-Kong_2024.pdf
 
Research Methodolgy & Intellectual Property Rights Series 2
Research Methodolgy & Intellectual Property Rights Series 2Research Methodolgy & Intellectual Property Rights Series 2
Research Methodolgy & Intellectual Property Rights Series 2
 
Piping and instrumentation diagram p.pdf
Piping and instrumentation diagram p.pdfPiping and instrumentation diagram p.pdf
Piping and instrumentation diagram p.pdf
 
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas SachpazisSeismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
 
AI in Healthcare Innovative use cases and applications.pdf
AI in Healthcare Innovative use cases and applications.pdfAI in Healthcare Innovative use cases and applications.pdf
AI in Healthcare Innovative use cases and applications.pdf
 
ALCOHOL PRODUCTION- Beer Brewing Process.pdf
ALCOHOL PRODUCTION- Beer Brewing Process.pdfALCOHOL PRODUCTION- Beer Brewing Process.pdf
ALCOHOL PRODUCTION- Beer Brewing Process.pdf
 
Artificial Intelligence in due diligence
Artificial Intelligence in due diligenceArtificial Intelligence in due diligence
Artificial Intelligence in due diligence
 
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfInstruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
 
Passive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.pptPassive Air Cooling System and Solar Water Heater.ppt
Passive Air Cooling System and Solar Water Heater.ppt
 
Final DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualFinal DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manual
 
Raashid final report on Embedded Systems
Raashid final report on Embedded SystemsRaashid final report on Embedded Systems
Raashid final report on Embedded Systems
 

Exploring composer in drupal 8 with drupal project - salva molina

  • 1. EXPLORING COMPOSER IN DRUPAL 8 WITH DRUPAL-PROJECT Salvador Molina #DrupalCampEs www.adevfromtheplains.com Original talk by @isholgueras
  • 2. Greetings! I am Salva Molina ● Drupal Developer @ Bluespark. ● Slv_ /”self”/ in drupal.org. ● @Salva_bg on Twitter. ● https://github.com/salvamomo/. ● Rants, cries and nonsense at http://adevfromtheplains.com.
  • 3. Let’s talk about Composer 1. Composer basics. 1. Drupal-project. 1. Wrapping up.
  • 4. Composer basics - What is it? - Main Commands
  • 5. What is Composer? ● Dependency Manager. ● Not a Package Manager. ● Inspired by node’s npm and Ruby’s bundler.
  • 6. composer.json { "name": "my-vendor/my-project", "require": { "monolog/monolog": "1.0.*", "consolidation/robo": "^1.0" }, "require-dev": { "phpunit/phpunit": "~4.8" }, "minimum-stability": "dev", "prefer-stable": true, }
  • 7. composer.lock { "name": "consolidation/robo", "version": "1.0.5", "source": { "type": "git", "url": "https://github.com/consolidation/Robo.git", "reference": "1f1d92807f72901e049e9df048b412c3bc3652c9" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/consolidation/Robo/zipball/d064", "Reference": "1f1d92807f72901e049e9df048b412c3bc3652c9", },
  • 8. Installing Composer ● Global is better curl -sS https://getcomposer.org/installer | sudo php -- -- install-dir=/usr/local/bin --filename=composer
  • 10. Main commands ▷ composer init ▷ composer install 1 2 3
  • 11. Main commands ▷ composer init ▷ composer install ▷ composer update 1 2 3
  • 12. Main commands ▷ composer init ▷ composer install ▷ composer update ▷ composer require
  • 13. Vendor and autoload.php Autoload.php Has all registered classes and namespaces. /vendor Directory where libraries are stored. <?php // File: ./app.php require_once “./vendor/autoload.php”
  • 14. What is Autoload.php for? DependenciesAutoload.phpCustom code
  • 15.
  • 16. Drupal-project - What is Drupal-project? - Daily management - Under the hood
  • 17. Drupal Composer Working group for making Drupal work with Composer: http://drupal-composer.org Composer template for Drupal Projects: https://github.com/drupal-composer/drupal-project Drupal Project
  • 18. What does the template do? ● Installs Drupal in the web directory. ● Alters Drupal’s default autoloader to point at the one generated by composer, in the project root.
  • 19. What does the template do? Modules (packages of type drupal-module) will be placed in web/modules/contrib/ Themes (packages of type drupal-theme) will be placed in web/themes/contrib/ Profiles (packages of type drupal-profile) will be placed in web/profiles/contrib/
  • 20. What does the template do? Creates default writable versions of settings.php and services.yml. Creates sites/default/files-directory. Latest version of drush is installed locally for use at vendor/bin/drush. Latest version of DrupalConsole is installed locally for use at vendor/bin/drupal.
  • 21. In one command composer create-project drupal-composer/drupal-project:8.x-dev my-project-dir --stability dev --no-interaction my-project-dir ├── .gitignore ├── composer.json ├── composer.lock ├── config ├── drush ├── LICENSE ├── phpunit.xml.dist ├── README.md ├── scripts ├── vendor └── web
  • 22. Daily management The bread and butter of Drupal with drupal-project
  • 23. Starting from scratch > ~ $ git clone https://git/repo.git > ~ $ cd repo > ~/repo $ composer install > ~/repo $ cd web > ~/repo/web $ drush site-install profile ...
  • 24. Managing contrib Download, delete or update modules, themes or profiles:> ~/repo $ composer require drupal/ds > ~/repo $ composer remove drupal/ds > ~/repo $ composer update drupal/ds* > ~/repo/web $ drush ...
  • 25. Managing core Clean repo (git stash) > ~/repo $ composer update drupal/core --with-dependencies > ~/repo $ git diff
  • 26. Managing core If there are no conflicts: > ~/repo/web $ drush updb > ~/repo $ git commit -am “Updated core”
  • 27. Managing core If there are: Create a branch. Fix conflicts (.htaccess, robots.txt,...). Merge to master (1 commit if possible). Done!
  • 28. Applying patches composer.json: "extra": { "patches": { "drupal/ds": { "Patch description #2334434": "URL to patch" } } }
  • 30. Drupal-scaffold Part of the “scripts” attribute in composer.json Downloads files (index.php, update.php, etc...) Create new ones from templates default.settings.php -> settings.php
  • 31. Drush policy Avoid execution of drush pm-update Alter drush-aliases Avoid writing in @prod * *Needs to be added: https://github.com/drush-ops/drush/blob/8.x/examples/policy.drush.inc
  • 33. Grab them by the policy. Drush policy
  • 35. Pros Amazing dependency management. All contrib out of git. Composer hooks (pre, post, …). Standardized. Patches. Also for D7.
  • 36. Cons Much more strict than the “classical way” Another point of failure, composer. If github is down… If packagist is down… If your internet is slow...
  • 37. Do we commit “vendor/”? Software distribution VS software deployment. Robustness of deployments. Git history. Git size. Best practices. Code auditing. Does one size fit all?
  • 38. To git... Robustness in deployments. Easier and more straightforward deployments. Proper auditing of all production code. Clear, accessible history of code changes. Small amount of extra work (once) to ensure right process for every possible library. Unneeded complexity increase in deployments, with more chance for builds to break due to external systems. No auditing of code changes. A bit smaller code repository. Or not to git?
  • 39.
  • 41. SPAM #OPHPEN_READS A #PHP reading club in Spanish. http://www.isholgueras.com/blog/ophpenreads-iniciamos-el-club-de-lectura-de-libros-tecnicos https://www.youtube.com/playlist?list=PL3NN5-oQnuvrkvOrdn1hzOHIlQOe7Gk5k
  • 42. ¡Gracias! Thank you! Twitter: @Salva_bg Blog: http://adevfromtheplains.com #DrupalCampEs

Editor's Notes

  1. “Extra” doesn’t look right here. Wasn’t it “scripts”?
  2. Contrib out of git, optionally!