SlideShare une entreprise Scribd logo
1  sur  32
Composer JSON kills
make files
DrupalCamp Baltics 2017
• Perttu Ehn
https://www.drupal.org/u/rpsu
@ropsue
• Competence manager at Exove Ltd www.exove.com
• 11 years of Drupal, contrib module maintainer
• Motto:
Q: Can this be done?
A: Yes. Most certainly. It’s just a matter of the size of your
budget and available timeframe.
Very briefly about me
Drush .make files are great. Really.
Composer.json keeps track of and
updates your codebase easier.
Topics
• Drush Recap
• Composer
• Workflow with the Composer
• Recipes
•Semantic versioning
Drush recap
• Drush is a command line shell and Unix scripting interface for
Drupal. 1)
• Can build the codebase based on the recipe (.make-file)
$ drush make project.make
• Can download and enable modules, themes from drupal.org
$ drush dl regcode_simple
$ drush en regcode_simple
• Set variables, reset passwords, rebuild or revert features…
$ drush uli admin
• Hooks for custom commands to do practically anything with Drupal
1) www.drush.org
Drush recap
• Drush .make file is a fixed yet incomplete recipe for
the codebase
• Drush .make file must be manually maintained
• Drush does not have a concept of “dependency” for
code downloads
• Composer is a tool for dependency management in
PHP
• Dependency manager, per project, within a project
• Node: npm
• Ruby: bundler
Composer
• Composer does everything with the codebase Drush
does, but better
• Composer Does not touch Drupal
.. however, Drupal console does
• Composer may be installed globally or per project 1)
• Composer == composer.phar -file, “Php ARchive”
Composer
1) https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx
• Set up a project repository
• Add component in project root
$ composer require drupal/drupal
Basics
$ composer require drupal/drupal
Using version ^8.4 for drupal/drupal
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 3 installs, 0 updates, 0 removals
- Installing wikimedia/composer-merge-plugin
(v1.4.1): Downloading (100%)
- Installing composer/installers (v1.4.0):
Downloading (100%)
- Installing drupal/drupal (8.4.0): Downloading
(100%)
Writing lock file
Generating autoload files
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
composer.json
composer.lock
vendor/autoload.php
vendor/composer/
vendor/drupal/
vendor/wikimedia/
vendor/drupal/drupal/index.php
• Dependencies were resolved and downloaded?
=> Write composer.lock
• Something odd happened?
=> Revert the already made changes in
composer.json
Double or nothing
{
"require": {
"drupal/drupal": "^8.4"
}
}
Drupal: composer.json
• 258 lines of json-code
• Specifies the exact version of Drupal 8 (8.4.0)
• Dependencies listed and specified in detail, too
• With composer.lock -file the whole codebase can be
rebuilt to the last bit
• Loose constraints do not affect the reproducibility of
the codebase
composer.lock
• Use Composer template for Drupal
$ composer create-project drupal-
composer/drupal-project:8.x-dev coolio --
stability dev --no-interaction --prefer-dist
• It comes with steroids!
Workflow
• Use Composer template for Drupal
$ composer create-project drupal-
composer/drupal-project:8.x-dev coolio --
stability dev --no-interaction --prefer-dist
• create-project creates a new project from an
existing project (think git clone)
Workflow
• Use Composer template for Drupal
$ composer create-project drupal-
composer/drupal-project:8.x-dev coolio --
stability dev --no-interaction --prefer-dist
• Use Composer template for Drupal as the base
• 8.x project version (relates to the Drupal core
version)
• -dev use dev -version, ie. a git commit (latest one
in this case)
Workflow
• Use Composer template for Drupal
$ composer create-project drupal-
composer/drupal-project:8.x-dev coolio --
stability dev --no-interaction --prefer-dist
• coolio is the directory where the project will be
created
• composer.json and composer.lock files will be
there
Workflow
• Use Composer template for Drupal
$ composer create-project drupal-
composer/drupal-project:8.x-dev coolio --
stability dev --no-interaction --prefer-dist
• --stability dev Minimum stability of package
• --no-interaction Do not ask any interactive
question
Workflow
• Use Composer template for Drupal
$ composer create-project drupal-
composer/drupal-project:8.x-dev coolio --
stability dev --no-interaction --prefer-dist
• --prefer-dist Prefer distributions over source,
ie. use vendor zip/gzip/tar/whatever if found. Faster.
Workflow
• Web root is in
coolio/web
• All libraries are protected from direct access
coolio/vendor/*
• vendor code rarely needs to be accessible directly from
the world
• index.php
• core/update.php (well...)
Folder structure
• Download module
$ drush dl regcode_simple-8.1
• Add requirement manually to the .make -file
• Remove unnecessary code manually
Recipes
Get some modules (.make, .make.yml)
$ composer require drupal/ctools
$ composer require drupal/commerce:2.0-beta3
• List the modules you have with Drupal:
$ composer show drupal/*
• Remove affects composer.json and the codebase, too
$ composer remove drupal/ctools
Recipes
Get some modules (composer)
zsh requires quoted parameter when it contains an asterisk: $ composer show "drupal/*"
• Commit composer.json and composer.lock -files to
Git
• Don’t commit (.gitignore): vendor/*
What should I commit?
1. Clone project repository.
2. Run composer install
• Composer reads composer.lock -file
• Composer retrieves all the required dependencies
• Composer generates autoloader
3. That’s it!
(+ additional vagrant up or Docker magix)
Team mates up-to-date?
• Run composer update to get the latest versions
available (within constraints!)
• Updates code
• Write updates to composer.lock -file
• Change version (constraints)
$ composer require drupal/commerce:2.*
zsh requires quoted parameter when it contains an asterisk: $ composer show "drupal/*"
Update module versions?
• Three digits; 1.2.3
• 1st changes might be backwards incompatible (major
release)
• API removals, API changes
• 2nd changes with API additions, new features (minor
release)
• 3rd changes with bug fixes (patch releaser)
Semantic versioning
Range
• Comparison operators, specified range of allowed
versions
>=1.0
>=1.0 <2.0
>=1.0 <1.1 || >=1.2
1.0 - 2.0
Wildcard
• * is a wildcard: 1.0.* is the
equivalent of >=1.0 <1.1
https://getcomposer.org/doc/articles/versions.md
Constraints
Tilde
• ~ specifies a minimum version, but allows the last
digit specified to go up:
”~1.2” is equal to ”>= 1.2 < 2.*”
Caret
• ^ sticks closer to semantic versioning; sub-major
version updates should not break anything: ”^1.2.3”
is equivalent to ”>=1.2.3 <2.0.0”
https://getcomposer.org/doc/articles/versions.md
Constraints
Take also look at these
• Composer template for Drupal projects
https://github.com/drupal-composer/drupal-project
• Improving your Drupal 8 development workflow
by Jesus Manuel Olivas
http://weknowinc.com/talks/2016/drupalgov-workflow
• Drupal Console Docs
https://drupalconsole.com/docs
Time for questions!
• Drush Recap
• Composer
• Workflow with the Composer
• Recipes
•Semantic versioning
Thank you!

Contenu connexe

Tendances

Automating & Integrating Pantheon with JIRA, Slack, Jenkins and More
Automating & Integrating Pantheon with JIRA, Slack, Jenkins and MoreAutomating & Integrating Pantheon with JIRA, Slack, Jenkins and More
Automating & Integrating Pantheon with JIRA, Slack, Jenkins and MorePantheon
 
Developing and Deploying PHP with Docker
Developing and Deploying PHP with DockerDeveloping and Deploying PHP with Docker
Developing and Deploying PHP with DockerPatrick Mizer
 
Drupal contrib module maintaining
Drupal contrib module maintainingDrupal contrib module maintaining
Drupal contrib module maintainingAndrii Podanenko
 
IBM Drupal Users Group Discussion on Managing and Deploying Configuration
IBM Drupal Users Group Discussion on Managing and Deploying ConfigurationIBM Drupal Users Group Discussion on Managing and Deploying Configuration
IBM Drupal Users Group Discussion on Managing and Deploying ConfigurationDevelopment Seed
 
Composer Tools & Frameworks for Drupal
Composer Tools & Frameworks for DrupalComposer Tools & Frameworks for Drupal
Composer Tools & Frameworks for DrupalPantheon
 
DrupalCon Los Angeles - Continuous Integration Toolbox
DrupalCon Los Angeles - Continuous Integration ToolboxDrupalCon Los Angeles - Continuous Integration Toolbox
DrupalCon Los Angeles - Continuous Integration ToolboxAndrii Podanenko
 
Dockercon EU 2014
Dockercon EU 2014Dockercon EU 2014
Dockercon EU 2014Rafe Colton
 
Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)Ontico
 
Scalable Cloud-Native Masterless Puppet, with PuppetDB and Bolt, Craig Watson...
Scalable Cloud-Native Masterless Puppet, with PuppetDB and Bolt, Craig Watson...Scalable Cloud-Native Masterless Puppet, with PuppetDB and Bolt, Craig Watson...
Scalable Cloud-Native Masterless Puppet, with PuppetDB and Bolt, Craig Watson...Puppet
 
Getting Started with Docker
Getting Started with Docker Getting Started with Docker
Getting Started with Docker Anup Segu
 
Live deployment, ci, drupal
Live deployment, ci, drupalLive deployment, ci, drupal
Live deployment, ci, drupalAndrii Podanenko
 
Let's go HTTPS-only! - More Than Buying a Certificate
Let's go HTTPS-only! - More Than Buying a CertificateLet's go HTTPS-only! - More Than Buying a Certificate
Let's go HTTPS-only! - More Than Buying a CertificateSteffen Gebert
 
Drupal 8 DevOps . Profile and SQL flows.
Drupal 8 DevOps . Profile and SQL flows.Drupal 8 DevOps . Profile and SQL flows.
Drupal 8 DevOps . Profile and SQL flows.Andrii Podanenko
 
CI : the first_step: Auto Testing with CircleCI - (MOSG)
CI : the first_step: Auto Testing with CircleCI - (MOSG)CI : the first_step: Auto Testing with CircleCI - (MOSG)
CI : the first_step: Auto Testing with CircleCI - (MOSG)Soshi Nemoto
 
MoldCamp - multidimentional testing workflow. CIBox.
MoldCamp  - multidimentional testing workflow. CIBox.MoldCamp  - multidimentional testing workflow. CIBox.
MoldCamp - multidimentional testing workflow. CIBox.Andrii Podanenko
 
Docker at Djangocon 2013 | Talk by Ken Cochrane
Docker at Djangocon 2013 | Talk by Ken CochraneDocker at Djangocon 2013 | Talk by Ken Cochrane
Docker at Djangocon 2013 | Talk by Ken CochranedotCloud
 
Integrate Openshift with Cloudforms
Integrate Openshift with CloudformsIntegrate Openshift with Cloudforms
Integrate Openshift with CloudformsMichael Lessard
 

Tendances (20)

Automating & Integrating Pantheon with JIRA, Slack, Jenkins and More
Automating & Integrating Pantheon with JIRA, Slack, Jenkins and MoreAutomating & Integrating Pantheon with JIRA, Slack, Jenkins and More
Automating & Integrating Pantheon with JIRA, Slack, Jenkins and More
 
Developing and Deploying PHP with Docker
Developing and Deploying PHP with DockerDeveloping and Deploying PHP with Docker
Developing and Deploying PHP with Docker
 
Drupal contrib module maintaining
Drupal contrib module maintainingDrupal contrib module maintaining
Drupal contrib module maintaining
 
IBM Drupal Users Group Discussion on Managing and Deploying Configuration
IBM Drupal Users Group Discussion on Managing and Deploying ConfigurationIBM Drupal Users Group Discussion on Managing and Deploying Configuration
IBM Drupal Users Group Discussion on Managing and Deploying Configuration
 
Composer Tools & Frameworks for Drupal
Composer Tools & Frameworks for DrupalComposer Tools & Frameworks for Drupal
Composer Tools & Frameworks for Drupal
 
DrupalCon Los Angeles - Continuous Integration Toolbox
DrupalCon Los Angeles - Continuous Integration ToolboxDrupalCon Los Angeles - Continuous Integration Toolbox
DrupalCon Los Angeles - Continuous Integration Toolbox
 
Dockercon EU 2014
Dockercon EU 2014Dockercon EU 2014
Dockercon EU 2014
 
Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)Использование Docker в CI / Александр Акбашев (HERE Technologies)
Использование Docker в CI / Александр Акбашев (HERE Technologies)
 
Puppeteerのお話
Puppeteerのお話Puppeteerのお話
Puppeteerのお話
 
Scalable Cloud-Native Masterless Puppet, with PuppetDB and Bolt, Craig Watson...
Scalable Cloud-Native Masterless Puppet, with PuppetDB and Bolt, Craig Watson...Scalable Cloud-Native Masterless Puppet, with PuppetDB and Bolt, Craig Watson...
Scalable Cloud-Native Masterless Puppet, with PuppetDB and Bolt, Craig Watson...
 
Getting Started with Docker
Getting Started with Docker Getting Started with Docker
Getting Started with Docker
 
Perlbrew
PerlbrewPerlbrew
Perlbrew
 
Live deployment, ci, drupal
Live deployment, ci, drupalLive deployment, ci, drupal
Live deployment, ci, drupal
 
Let's go HTTPS-only! - More Than Buying a Certificate
Let's go HTTPS-only! - More Than Buying a CertificateLet's go HTTPS-only! - More Than Buying a Certificate
Let's go HTTPS-only! - More Than Buying a Certificate
 
Drupal 8 DevOps . Profile and SQL flows.
Drupal 8 DevOps . Profile and SQL flows.Drupal 8 DevOps . Profile and SQL flows.
Drupal 8 DevOps . Profile and SQL flows.
 
CI : the first_step: Auto Testing with CircleCI - (MOSG)
CI : the first_step: Auto Testing with CircleCI - (MOSG)CI : the first_step: Auto Testing with CircleCI - (MOSG)
CI : the first_step: Auto Testing with CircleCI - (MOSG)
 
MoldCamp - multidimentional testing workflow. CIBox.
MoldCamp  - multidimentional testing workflow. CIBox.MoldCamp  - multidimentional testing workflow. CIBox.
MoldCamp - multidimentional testing workflow. CIBox.
 
Docker at Djangocon 2013 | Talk by Ken Cochrane
Docker at Djangocon 2013 | Talk by Ken CochraneDocker at Djangocon 2013 | Talk by Ken Cochrane
Docker at Djangocon 2013 | Talk by Ken Cochrane
 
Integrate Openshift with Cloudforms
Integrate Openshift with CloudformsIntegrate Openshift with Cloudforms
Integrate Openshift with Cloudforms
 
Django via Docker
Django via DockerDjango via Docker
Django via Docker
 

Similaire à Composer JSON kills make files

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
 
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
 
Exploring composer in drupal 8 with drupal project - salva molina
Exploring composer in drupal 8 with drupal project - salva molinaExploring composer in drupal 8 with drupal project - salva molina
Exploring composer in drupal 8 with drupal project - salva molinaSalvador Molina (Slv_)
 
Introduction to Composer for Drupal
Introduction to Composer for DrupalIntroduction to Composer for Drupal
Introduction to Composer for DrupalLuc Bézier
 
Drupal 8 improvements for developer productivity php symfony and more
Drupal 8 improvements for developer productivity  php symfony and moreDrupal 8 improvements for developer productivity  php symfony and more
Drupal 8 improvements for developer productivity php symfony and moreAcquia
 
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuis Rodríguez Castromil
 
Efficient development workflows with composer
Efficient development workflows with composerEfficient development workflows with composer
Efficient development workflows with composernuppla
 
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...Docker, Inc.
 
Efficient development workflows with composer
Efficient development workflows with composerEfficient development workflows with composer
Efficient development workflows with composernuppla
 
Super powered Drupal development with docker
Super powered Drupal development with dockerSuper powered Drupal development with docker
Super powered Drupal development with dockerMaciej Lukianski
 
Docker 102 - Immutable Infrastructure
Docker 102 - Immutable InfrastructureDocker 102 - Immutable Infrastructure
Docker 102 - Immutable InfrastructureAdrian Otto
 
Stop making, start composing - Using Composer for Drupal development
Stop making, start composing - Using Composer for Drupal developmentStop making, start composing - Using Composer for Drupal development
Stop making, start composing - Using Composer for Drupal developmentkaspergarnaes
 
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
 
Leveraging Composer in Existing Projects
Leveraging Composer in Existing ProjectsLeveraging Composer in Existing Projects
Leveraging Composer in Existing ProjectsMark Niebergall
 
DevOPS training - Day 2/2
DevOPS training - Day 2/2DevOPS training - Day 2/2
DevOPS training - Day 2/2Vincent Mercier
 

Similaire à Composer JSON kills make files (20)

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
 
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
 
Exploring composer in drupal 8 with drupal project - salva molina
Exploring composer in drupal 8 with drupal project - salva molinaExploring composer in drupal 8 with drupal project - salva molina
Exploring composer in drupal 8 with drupal project - salva molina
 
Introduction to Composer for Drupal
Introduction to Composer for DrupalIntroduction to Composer for Drupal
Introduction to Composer for Drupal
 
Drupal 8 improvements for developer productivity php symfony and more
Drupal 8 improvements for developer productivity  php symfony and moreDrupal 8 improvements for developer productivity  php symfony and more
Drupal 8 improvements for developer productivity php symfony and more
 
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
 
Efficient development workflows with composer
Efficient development workflows with composerEfficient development workflows with composer
Efficient development workflows with composer
 
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
The Tale of a Docker-based Continuous Delivery Pipeline by Rafe Colton (ModCl...
 
Composer
ComposerComposer
Composer
 
Efficient development workflows with composer
Efficient development workflows with composerEfficient development workflows with composer
Efficient development workflows with composer
 
Super powered Drupal development with docker
Super powered Drupal development with dockerSuper powered Drupal development with docker
Super powered Drupal development with docker
 
Docker 102 - Immutable Infrastructure
Docker 102 - Immutable InfrastructureDocker 102 - Immutable Infrastructure
Docker 102 - Immutable Infrastructure
 
Stop making, start composing - Using Composer for Drupal development
Stop making, start composing - Using Composer for Drupal developmentStop making, start composing - Using Composer for Drupal development
Stop making, start composing - Using Composer for Drupal development
 
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
 
Leveraging Composer in Existing Projects
Leveraging Composer in Existing ProjectsLeveraging Composer in Existing Projects
Leveraging Composer in Existing Projects
 
DevOPS training - Day 2/2
DevOPS training - Day 2/2DevOPS training - Day 2/2
DevOPS training - Day 2/2
 
Containerization using docker and its applications
Containerization using docker and its applicationsContainerization using docker and its applications
Containerization using docker and its applications
 

Dernier

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
 
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
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 

Dernier (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

Composer JSON kills make files

  • 1. Composer JSON kills make files DrupalCamp Baltics 2017
  • 2. • Perttu Ehn https://www.drupal.org/u/rpsu @ropsue • Competence manager at Exove Ltd www.exove.com • 11 years of Drupal, contrib module maintainer • Motto: Q: Can this be done? A: Yes. Most certainly. It’s just a matter of the size of your budget and available timeframe. Very briefly about me
  • 3. Drush .make files are great. Really. Composer.json keeps track of and updates your codebase easier.
  • 4. Topics • Drush Recap • Composer • Workflow with the Composer • Recipes •Semantic versioning
  • 5. Drush recap • Drush is a command line shell and Unix scripting interface for Drupal. 1) • Can build the codebase based on the recipe (.make-file) $ drush make project.make • Can download and enable modules, themes from drupal.org $ drush dl regcode_simple $ drush en regcode_simple • Set variables, reset passwords, rebuild or revert features… $ drush uli admin • Hooks for custom commands to do practically anything with Drupal 1) www.drush.org
  • 6. Drush recap • Drush .make file is a fixed yet incomplete recipe for the codebase • Drush .make file must be manually maintained • Drush does not have a concept of “dependency” for code downloads
  • 7. • Composer is a tool for dependency management in PHP • Dependency manager, per project, within a project • Node: npm • Ruby: bundler Composer
  • 8. • Composer does everything with the codebase Drush does, but better • Composer Does not touch Drupal .. however, Drupal console does • Composer may be installed globally or per project 1) • Composer == composer.phar -file, “Php ARchive” Composer 1) https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx
  • 9. • Set up a project repository • Add component in project root $ composer require drupal/drupal Basics
  • 10. $ composer require drupal/drupal Using version ^8.4 for drupal/drupal ./composer.json has been created Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 3 installs, 0 updates, 0 removals - Installing wikimedia/composer-merge-plugin (v1.4.1): Downloading (100%) - Installing composer/installers (v1.4.0): Downloading (100%) - Installing drupal/drupal (8.4.0): Downloading (100%) Writing lock file Generating autoload files Loading composer repositories with package information Updating dependencies (including require-dev) Nothing to install or update Generating autoload files
  • 12. • Dependencies were resolved and downloaded? => Write composer.lock • Something odd happened? => Revert the already made changes in composer.json Double or nothing
  • 14. • 258 lines of json-code • Specifies the exact version of Drupal 8 (8.4.0) • Dependencies listed and specified in detail, too • With composer.lock -file the whole codebase can be rebuilt to the last bit • Loose constraints do not affect the reproducibility of the codebase composer.lock
  • 15. • Use Composer template for Drupal $ composer create-project drupal- composer/drupal-project:8.x-dev coolio -- stability dev --no-interaction --prefer-dist • It comes with steroids! Workflow
  • 16. • Use Composer template for Drupal $ composer create-project drupal- composer/drupal-project:8.x-dev coolio -- stability dev --no-interaction --prefer-dist • create-project creates a new project from an existing project (think git clone) Workflow
  • 17. • Use Composer template for Drupal $ composer create-project drupal- composer/drupal-project:8.x-dev coolio -- stability dev --no-interaction --prefer-dist • Use Composer template for Drupal as the base • 8.x project version (relates to the Drupal core version) • -dev use dev -version, ie. a git commit (latest one in this case) Workflow
  • 18. • Use Composer template for Drupal $ composer create-project drupal- composer/drupal-project:8.x-dev coolio -- stability dev --no-interaction --prefer-dist • coolio is the directory where the project will be created • composer.json and composer.lock files will be there Workflow
  • 19. • Use Composer template for Drupal $ composer create-project drupal- composer/drupal-project:8.x-dev coolio -- stability dev --no-interaction --prefer-dist • --stability dev Minimum stability of package • --no-interaction Do not ask any interactive question Workflow
  • 20. • Use Composer template for Drupal $ composer create-project drupal- composer/drupal-project:8.x-dev coolio -- stability dev --no-interaction --prefer-dist • --prefer-dist Prefer distributions over source, ie. use vendor zip/gzip/tar/whatever if found. Faster. Workflow
  • 21. • Web root is in coolio/web • All libraries are protected from direct access coolio/vendor/* • vendor code rarely needs to be accessible directly from the world • index.php • core/update.php (well...) Folder structure
  • 22. • Download module $ drush dl regcode_simple-8.1 • Add requirement manually to the .make -file • Remove unnecessary code manually Recipes Get some modules (.make, .make.yml)
  • 23. $ composer require drupal/ctools $ composer require drupal/commerce:2.0-beta3 • List the modules you have with Drupal: $ composer show drupal/* • Remove affects composer.json and the codebase, too $ composer remove drupal/ctools Recipes Get some modules (composer) zsh requires quoted parameter when it contains an asterisk: $ composer show "drupal/*"
  • 24. • Commit composer.json and composer.lock -files to Git • Don’t commit (.gitignore): vendor/* What should I commit?
  • 25. 1. Clone project repository. 2. Run composer install • Composer reads composer.lock -file • Composer retrieves all the required dependencies • Composer generates autoloader 3. That’s it! (+ additional vagrant up or Docker magix) Team mates up-to-date?
  • 26. • Run composer update to get the latest versions available (within constraints!) • Updates code • Write updates to composer.lock -file • Change version (constraints) $ composer require drupal/commerce:2.* zsh requires quoted parameter when it contains an asterisk: $ composer show "drupal/*" Update module versions?
  • 27. • Three digits; 1.2.3 • 1st changes might be backwards incompatible (major release) • API removals, API changes • 2nd changes with API additions, new features (minor release) • 3rd changes with bug fixes (patch releaser) Semantic versioning
  • 28. Range • Comparison operators, specified range of allowed versions >=1.0 >=1.0 <2.0 >=1.0 <1.1 || >=1.2 1.0 - 2.0 Wildcard • * is a wildcard: 1.0.* is the equivalent of >=1.0 <1.1 https://getcomposer.org/doc/articles/versions.md Constraints
  • 29. Tilde • ~ specifies a minimum version, but allows the last digit specified to go up: ”~1.2” is equal to ”>= 1.2 < 2.*” Caret • ^ sticks closer to semantic versioning; sub-major version updates should not break anything: ”^1.2.3” is equivalent to ”>=1.2.3 <2.0.0” https://getcomposer.org/doc/articles/versions.md Constraints
  • 30. Take also look at these • Composer template for Drupal projects https://github.com/drupal-composer/drupal-project • Improving your Drupal 8 development workflow by Jesus Manuel Olivas http://weknowinc.com/talks/2016/drupalgov-workflow • Drupal Console Docs https://drupalconsole.com/docs
  • 31. Time for questions! • Drush Recap • Composer • Workflow with the Composer • Recipes •Semantic versioning

Notes de l'éditeur

  1. Started as Product owner!
  2. who of you have used Drush? How about Drush .make files then?
  3. Dependencies in enabling models - because Drupal resolves them incomplete = no dependency -consept
  4. The require command adds new packages to the composer.json file from the current directory. If no file exists one will be created on the fly.
  5. $ ls -1 — now, where is my drupal? It’s in vendor -folder! because… we installed it as a component for the project
  6. https://packagist.org Packagist is the main Composer repository. It aggregates public PHP packages installable with Composer.
  7. “^8.” <= no version specified, so use (and lock to) the latest minor release.
  8. coolio can be omitted, too. Defaults to drupal-project.
  9. Code hosted elsewhere == pretty much everything added by Composer. Code hosted elsewhere (Drupal core, modules, libraries)
  10. Note: The ~ operator has an exception on its behavior for the major release number. This means for example that ~1 is the same as ~1.0 as it will not allow the major number to increase trying to keep backwards compatibility.
  11. Note: The ~ operator has an exception on its behavior for the major release number. This means for example that ~1 is the same as ~1.0 as it will not allow the major number to increase trying to keep backwards compatibility.
  12. Problem: -> Found and fixed a bug in a contrib module, and now you need to use your fixes (a patch file) from drupal.org? No prob. -> Perhaps you were lazy and never uploaded the patch? No prob either.
  13. Example code is modified version of https://donatstudios.com/Require-a-Remote-Zip-File-with-Composer
  14. Example code is modified version of https://donatstudios.com/Require-a-Remote-Zip-File-with-Composer
  15. default profile: standard
  16. example.com == target to sites/example.com folder