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.ppt
Composer tools and frameworks for drupal.pptComposer tools and frameworks for drupal.ppt
Composer tools and frameworks for drupal.pptPromet Source
 
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 & 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.ppt
Composer tools and frameworks for drupal.pptComposer tools and frameworks for drupal.ppt
Composer tools and frameworks for drupal.ppt
 
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 & 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

Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxSCMS School of Architecture
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdfKamal Acharya
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086anil_gaur
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARKOUSTAV SARKAR
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...soginsider
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersMairaAshraf6
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesMayuraD1
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdfKamal Acharya
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsvanyagupta248
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptMsecMca
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdfKamal Acharya
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...HenryBriggs2
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Call Girls Mumbai
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationBhangaleSonal
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptNANDHAKUMARA10
 

Recently uploaded (20)

Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 

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!