SlideShare una empresa de Scribd logo
1 de 26
Descargar para leer sin conexión
Composer & Drupal
Drupal Meetup Stuttgart
04.02.2016
Composer is a...
● Dependency Manager for PHP projects
-> Requirements like frameworks or libraries
● Package Manager for PHP packages
-> Globally installed tools, like Drush or Console
http://getcomposer.org
Why should we care?
● Avoiding dependency hell
● Getting off the island
● Don’t reinvent the wheel
● Proudly invented / found elsewhere (PIE)
● Everyone does it
● ~85.000 packages for PHP projects using Composer (2/2016)
Basic components
composer.json
-> Specifies requirements, sources and configuration
composer.lock
-> Lists installed dependencies with current versions
vendor folder
-> Dependencies (packages) will be installed here
Autoloader
-> Makes dependencies available to your project
PHP package repository: http://packagist.org
What’s a package?
Package =>
● Script
● Library
● Framework
identified by
"vendor/package name", e.g. "fabpot/php-cs-fixer"
Example
composer require andrioli/hello-composer:"@dev" php:">=5.3.0"
composer.json:
{
"require": {
"andrioli/hello-composer": "@dev",
"php": ">=5.3.0"
}
}
index.php:
<?php
require 'vendor/autoload.php';
print HelloWorldSay::hello();
Composer defaults to stable
versions, here we require dev
versions, too!
Requirement: Semantic versioning
3.6.18
[major].[minor].[patch]
[Breaking].[Feature].[Bugfix]
http://semver.org
Specify required versions
[vendor/package]:[version][@[dev|alpha|beta|RC|stable]
Composer supported version constraints:
Exact: 7.1.0 -> Exact version
Comparison: >=1.2
Range: 1.2 - 1.3
Wildcard: 7.1.*
Tilde: ~7.1.3 -> Next significant release, >= 7.1.3, < 7.2
Carét: ^7.1.0 -> Next major release, >= 7.1.0, < 8.0.0
One thing to consider
“just edit your composer.json and add…”
[SeldJsonLintParsingException]
"./composer.json" does not contain valid JSON
Warning: The lock file is not up to date with the latest changes
in composer.json. You may be getting outdated dependencies. Run
update to update them.
=> Use composer commands!
Start a new PHP project: composer init
1. Create your index.php: touch index.php
2. Create composer.json: composer init -n
3. Add requirements/dependencies
4. Add the autoloader to your index.php:
require 'vendor/autoload.php';
Specify requirements: composer require
composer require [ vendor/package ] [ vendor/package ] ...
composer require guzzlehttp/guzzle
composer require phpunit/phpunit --dev
Adds / updates dependencies in composer.json & composer.lock
Package only needed for development? Use --dev !
Install requirements: composer install
composer install
composer install --no-dev
Installs exact versions specified in composer.lock
For production environments, use --no-dev !
Update requirements: composer update
composer update
composer update [ vendor/package ] [ vendor/package ] ...
Installs the latest version of the specified packages
meeting the requirements in composer.json
Updates composer.lock accordingly
Remove requirements: composer remove
composer remove [ vendor/package ] [ vendor/package ] ...
Removes the specified package(s)
Removes requirements from composer.json
Updates composer.lock accordingly
More Composer goodies
● Installs from packagist, various vcs (git, svn, …), pear, zip and more
● Applies patches, if needed
● Supports scripts, e.g. "post-package-install"
● Supports plugins (functional extensions)
Some useful plugins:
composer/installers -> Scaffolding, type-dependent install folders
wikimedia/composer-merge-plugin -> merge multiple composer.json files
fxp/composer-asset-plugin -> manage NPM- / Bower packages (CSS/JS)
Using composer in Drupal projects
Some pitfalls here:
● Semantic versioning: 7.x-3.5, 8.x-4.0 ?
● Different types of packages (modules, themes, libraries)
● Different target folders, not just /vendor
● Dependencies in .info files
● Incompatible project metadata / vcs drupal.org <-> packagist.org
Solutions:
● Specialized package repository, packagist.drupal-composer.org
● Use project templates / skeletons!
Create a new Drupal project using a template
composer create-project drupal-composer/drupal-project:8.x-dev
myproject --stability dev --no-interaction
composer create-project drupal-composer/drupal-project:7.x-dev
myproject -s dev -n
https://github.com/drupal-composer/drupal-project
(just a starting point)
This means the dev version of the
template, not of Drupal!
It’s not Drupal, it’s best practice!
composer create-project symfony/framework-standard-edition
composer create-project yiisoft/yii2-app-basic
composer create-project laravel/laravel
…
Use it for scaffolding, profiles, install scripts, configuration, ...
Managing Drupal Module & Themes
composer require drupal/devel drupal/views
composer update drupal/linkit
composer remove drupal/webform
…
Composer takes care of dependencies, so e.g.
drupal/views includes drupal/ctools (D7)!
What about custom modules?
{
"name": "drubb/myownmodule”,
"description": "Just a little custom module.",
"type": "drubb-custom",
"homepage": "https://github.com/drubb/myownmodule/"
"require": {
"drupal/views": ">=7.3.1"
},
}
Optionally (if not using packagist), use composer-merge plugin to merge
your custom composer.json with the main composer.json of your project !
Remember composer-installers?
But I use Drush / Console / Bash already?
Great! Keep on using them!
Additionally use them in your Composer scripts!
"post-update-cmd": [
"drush updb",
"drush cc all",
"echo Updates completed!"
],
UI wanted ? Composer Manager Module!
Drush Wrapper: Composer Module!
drush composer require
drush composer install
drush composer update
…
https://drupal.org/project/composer
GIT Workflow
Development
git pull
composer install
composer require / update
git push
Add composer.json / composer.lock !
Exclude dependencies (/vendor) !
Default for upcoming Drupal 8.1 !
Production
git pull / checkout
composer install
Read on
Official Composer Documentation
https://getcomposer.org/doc
Composer the Right Way
http://www.slideshare.net/rdohms/composer-the-right-way-phpjhb15
Composer Cheat Sheet for Developers
http://composer.json.jolicode.com
Drupal Composer community initiative
http://drupal-composer.org
Slides:
http://www.slideshare.net/drubb

Más contenido relacionado

La actualidad más candente

Drupal Console Deep Dive: How to Develop Faster and Smarter on Drupal 8
Drupal Console Deep Dive: How to Develop Faster and Smarter on Drupal 8Drupal Console Deep Dive: How to Develop Faster and Smarter on Drupal 8
Drupal Console Deep Dive: How to Develop Faster and Smarter on Drupal 8Jake Borr
 
Drupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentDrupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentsparkfabrik
 
Odoo development workflow with pip and virtualenv
Odoo development workflow with pip and virtualenvOdoo development workflow with pip and virtualenv
Odoo development workflow with pip and virtualenvacsone
 
DevHub 3 - Composer plus Magento
DevHub 3 - Composer plus MagentoDevHub 3 - Composer plus Magento
DevHub 3 - Composer plus MagentoMagento Dev
 
Writing your Third Plugin
Writing your Third PluginWriting your Third Plugin
Writing your Third PluginJustin Ryan
 
Magento 2 Development
Magento 2 DevelopmentMagento 2 Development
Magento 2 DevelopmentDuke Dao
 
[drupalday2017] - REST in pieces
[drupalday2017] - REST in pieces[drupalday2017] - REST in pieces
[drupalday2017] - REST in piecesDrupalDay
 
Acquia BLT for the Win, or How to speed up the project setup, development an...
Acquia BLT for the Win, or  How to speed up the project setup, development an...Acquia BLT for the Win, or  How to speed up the project setup, development an...
Acquia BLT for the Win, or How to speed up the project setup, development an...DrupalCamp Kyiv
 
Jumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin ProgrammingJumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin ProgrammingDougal Campbell
 
Creating a Plug-In Architecture
Creating a Plug-In ArchitectureCreating a Plug-In Architecture
Creating a Plug-In Architectureondrejbalas
 
Dependency management in Magento with Composer
Dependency management in Magento with ComposerDependency management in Magento with Composer
Dependency management in Magento with ComposerManuele Menozzi
 
第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」
第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」
第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」Tsuyoshi Yamamoto
 
Django, What is it, Why is it cool?
Django, What is it, Why is it cool?Django, What is it, Why is it cool?
Django, What is it, Why is it cool?Tom Brander
 
Views plugins-in-d7-and-d8
Views plugins-in-d7-and-d8Views plugins-in-d7-and-d8
Views plugins-in-d7-and-d8Frank Holldorff
 
An easy guide to Plugin Development
An easy guide to Plugin DevelopmentAn easy guide to Plugin Development
An easy guide to Plugin DevelopmentShinichi Nishikawa
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to DjangoJames Casey
 
From Hacker to Programmer (w/ Webpack, Babel and React)
From Hacker to Programmer (w/ Webpack, Babel and React)From Hacker to Programmer (w/ Webpack, Babel and React)
From Hacker to Programmer (w/ Webpack, Babel and React)Joseph Chiang
 
Writing Software not Code with Cucumber
Writing Software not Code with CucumberWriting Software not Code with Cucumber
Writing Software not Code with CucumberBen Mabey
 

La actualidad más candente (20)

Drupal Console Deep Dive: How to Develop Faster and Smarter on Drupal 8
Drupal Console Deep Dive: How to Develop Faster and Smarter on Drupal 8Drupal Console Deep Dive: How to Develop Faster and Smarter on Drupal 8
Drupal Console Deep Dive: How to Develop Faster and Smarter on Drupal 8
 
Drupal 8 - Corso frontend development
Drupal 8 - Corso frontend developmentDrupal 8 - Corso frontend development
Drupal 8 - Corso frontend development
 
Odoo development workflow with pip and virtualenv
Odoo development workflow with pip and virtualenvOdoo development workflow with pip and virtualenv
Odoo development workflow with pip and virtualenv
 
DevHub 3 - Composer plus Magento
DevHub 3 - Composer plus MagentoDevHub 3 - Composer plus Magento
DevHub 3 - Composer plus Magento
 
Writing your Third Plugin
Writing your Third PluginWriting your Third Plugin
Writing your Third Plugin
 
Magento 2 Development
Magento 2 DevelopmentMagento 2 Development
Magento 2 Development
 
Django
DjangoDjango
Django
 
[drupalday2017] - REST in pieces
[drupalday2017] - REST in pieces[drupalday2017] - REST in pieces
[drupalday2017] - REST in pieces
 
Acquia BLT for the Win, or How to speed up the project setup, development an...
Acquia BLT for the Win, or  How to speed up the project setup, development an...Acquia BLT for the Win, or  How to speed up the project setup, development an...
Acquia BLT for the Win, or How to speed up the project setup, development an...
 
Jumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin ProgrammingJumping Into WordPress Plugin Programming
Jumping Into WordPress Plugin Programming
 
Creating a Plug-In Architecture
Creating a Plug-In ArchitectureCreating a Plug-In Architecture
Creating a Plug-In Architecture
 
Dependency management in Magento with Composer
Dependency management in Magento with ComposerDependency management in Magento with Composer
Dependency management in Magento with Composer
 
第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」
第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」
第1回名古屋Grails/Groogy勉強会「Grailsを始めてみよう!」
 
Django by rj
Django by rjDjango by rj
Django by rj
 
Django, What is it, Why is it cool?
Django, What is it, Why is it cool?Django, What is it, Why is it cool?
Django, What is it, Why is it cool?
 
Views plugins-in-d7-and-d8
Views plugins-in-d7-and-d8Views plugins-in-d7-and-d8
Views plugins-in-d7-and-d8
 
An easy guide to Plugin Development
An easy guide to Plugin DevelopmentAn easy guide to Plugin Development
An easy guide to Plugin Development
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
From Hacker to Programmer (w/ Webpack, Babel and React)
From Hacker to Programmer (w/ Webpack, Babel and React)From Hacker to Programmer (w/ Webpack, Babel and React)
From Hacker to Programmer (w/ Webpack, Babel and React)
 
Writing Software not Code with Cucumber
Writing Software not Code with CucumberWriting Software not Code with Cucumber
Writing Software not Code with Cucumber
 

Destacado

Composer para Gestão de Dependências - Encontro PHP - Season
Composer para Gestão de Dependências - Encontro PHP - SeasonComposer para Gestão de Dependências - Encontro PHP - Season
Composer para Gestão de Dependências - Encontro PHP - SeasonRogerio Prado de Jesus
 
Door Lites Kits
Door Lites KitsDoor Lites Kits
Door Lites KitsKN Crowder
 
State of the School Cover Slide
State of the School Cover SlideState of the School Cover Slide
State of the School Cover Slideuabsom
 
Teen Centre Job Reference(Ruth Nicholson)
Teen Centre Job Reference(Ruth Nicholson)Teen Centre Job Reference(Ruth Nicholson)
Teen Centre Job Reference(Ruth Nicholson)Shafer Johnson
 
My Self+Name,Nickname, Age3+ป.1+104+dltvengp1+54en p01 f02-4page
My Self+Name,Nickname, Age3+ป.1+104+dltvengp1+54en p01 f02-4pageMy Self+Name,Nickname, Age3+ป.1+104+dltvengp1+54en p01 f02-4page
My Self+Name,Nickname, Age3+ป.1+104+dltvengp1+54en p01 f02-4pagePrachoom Rangkasikorn
 
Composer the Right Way - PHPBNL16
Composer the Right Way - PHPBNL16Composer the Right Way - PHPBNL16
Composer the Right Way - PHPBNL16Rafael Dohms
 
SVG For Designers And Developers
SVG For Designers And DevelopersSVG For Designers And Developers
SVG For Designers And DevelopersDan Hiester
 
Composer The Right Way - PHPUGMRN
Composer The Right Way - PHPUGMRNComposer The Right Way - PHPUGMRN
Composer The Right Way - PHPUGMRNRafael Dohms
 
La condición moral del ser humano
La condición moral del ser humanoLa condición moral del ser humano
La condición moral del ser humanomanucor
 
Nursing aspects-of-ecp
Nursing aspects-of-ecpNursing aspects-of-ecp
Nursing aspects-of-ecpLupin
 
Lipovisor FR
Lipovisor FRLipovisor FR
Lipovisor FRlipovisor
 
experiential exerice : self competency
experiential exerice : self competency experiential exerice : self competency
experiential exerice : self competency khushbu chauhan
 
The use of EU Structural Funds in Italy to support the reuse of confiscated ...
The use of EU Structural Funds in Italy  to support the reuse of confiscated ...The use of EU Structural Funds in Italy  to support the reuse of confiscated ...
The use of EU Structural Funds in Italy to support the reuse of confiscated ...OpenCoesione
 
La cittadinanza attiva: Open data e monitoraggio civico con A Scuola di Open...
La cittadinanza attiva: Open data e monitoraggio civico con  A Scuola di Open...La cittadinanza attiva: Open data e monitoraggio civico con  A Scuola di Open...
La cittadinanza attiva: Open data e monitoraggio civico con A Scuola di Open...OpenCoesione
 
Role of Government Agencies, Challenges and Suggestions for Possible Avenue o...
Role of Government Agencies, Challenges and Suggestions for Possible Avenue o...Role of Government Agencies, Challenges and Suggestions for Possible Avenue o...
Role of Government Agencies, Challenges and Suggestions for Possible Avenue o...APNIC
 

Destacado (20)

Composer para Gestão de Dependências - Encontro PHP - Season
Composer para Gestão de Dependências - Encontro PHP - SeasonComposer para Gestão de Dependências - Encontro PHP - Season
Composer para Gestão de Dependências - Encontro PHP - Season
 
Door Lites Kits
Door Lites KitsDoor Lites Kits
Door Lites Kits
 
State of the School Cover Slide
State of the School Cover SlideState of the School Cover Slide
State of the School Cover Slide
 
Gráficas
GráficasGráficas
Gráficas
 
Teen Centre Job Reference(Ruth Nicholson)
Teen Centre Job Reference(Ruth Nicholson)Teen Centre Job Reference(Ruth Nicholson)
Teen Centre Job Reference(Ruth Nicholson)
 
My Self+Name,Nickname, Age3+ป.1+104+dltvengp1+54en p01 f02-4page
My Self+Name,Nickname, Age3+ป.1+104+dltvengp1+54en p01 f02-4pageMy Self+Name,Nickname, Age3+ป.1+104+dltvengp1+54en p01 f02-4page
My Self+Name,Nickname, Age3+ป.1+104+dltvengp1+54en p01 f02-4page
 
MHC CAPACITY
MHC CAPACITYMHC CAPACITY
MHC CAPACITY
 
2. h.c. anemia-c
2. h.c. anemia-c2. h.c. anemia-c
2. h.c. anemia-c
 
Composer the Right Way - PHPBNL16
Composer the Right Way - PHPBNL16Composer the Right Way - PHPBNL16
Composer the Right Way - PHPBNL16
 
SVG For Designers And Developers
SVG For Designers And DevelopersSVG For Designers And Developers
SVG For Designers And Developers
 
Composer The Right Way - PHPUGMRN
Composer The Right Way - PHPUGMRNComposer The Right Way - PHPUGMRN
Composer The Right Way - PHPUGMRN
 
La condición moral del ser humano
La condición moral del ser humanoLa condición moral del ser humano
La condición moral del ser humano
 
Nursing aspects-of-ecp
Nursing aspects-of-ecpNursing aspects-of-ecp
Nursing aspects-of-ecp
 
Guias sexto primer periodo
Guias sexto primer periodoGuias sexto primer periodo
Guias sexto primer periodo
 
Lipovisor FR
Lipovisor FRLipovisor FR
Lipovisor FR
 
experiential exerice : self competency
experiential exerice : self competency experiential exerice : self competency
experiential exerice : self competency
 
The use of EU Structural Funds in Italy to support the reuse of confiscated ...
The use of EU Structural Funds in Italy  to support the reuse of confiscated ...The use of EU Structural Funds in Italy  to support the reuse of confiscated ...
The use of EU Structural Funds in Italy to support the reuse of confiscated ...
 
La cittadinanza attiva: Open data e monitoraggio civico con A Scuola di Open...
La cittadinanza attiva: Open data e monitoraggio civico con  A Scuola di Open...La cittadinanza attiva: Open data e monitoraggio civico con  A Scuola di Open...
La cittadinanza attiva: Open data e monitoraggio civico con A Scuola di Open...
 
MBA in Marketing, Unitedworld School of Business
MBA in Marketing, Unitedworld School of BusinessMBA in Marketing, Unitedworld School of Business
MBA in Marketing, Unitedworld School of Business
 
Role of Government Agencies, Challenges and Suggestions for Possible Avenue o...
Role of Government Agencies, Challenges and Suggestions for Possible Avenue o...Role of Government Agencies, Challenges and Suggestions for Possible Avenue o...
Role of Government Agencies, Challenges and Suggestions for Possible Avenue o...
 

Similar a Composer & Drupal

Efficient development workflows with composer
Efficient development workflows with composerEfficient development workflows with composer
Efficient development workflows with composernuppla
 
Efficient development workflows with composer
Efficient development workflows with composerEfficient development workflows with composer
Efficient development workflows with composernuppla
 
Managing your Drupal project with Composer
Managing your Drupal project with ComposerManaging your Drupal project with Composer
Managing your Drupal project with ComposerMatt Glaman
 
Dependency management with Composer
Dependency management with ComposerDependency management with Composer
Dependency management with ComposerJason Grimes
 
Composer JSON kills make files
Composer JSON kills make filesComposer JSON kills make files
Composer JSON kills make filesropsu
 
Composer Tools & Frameworks for Drupal
Composer Tools & Frameworks for DrupalComposer Tools & Frameworks for Drupal
Composer Tools & Frameworks for DrupalPantheon
 
Composer Best Practices
Composer Best PracticesComposer Best Practices
Composer Best PracticesAbid Malik
 
Composer Best Practices
Composer Best PracticesComposer Best Practices
Composer Best PracticesAbid Malik
 
Composer Best Practices.pdf
Composer Best Practices.pdfComposer Best Practices.pdf
Composer Best Practices.pdfAbid Malik
 
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
 
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 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
 
Using Composer with Drupal and Drush
Using Composer with Drupal and DrushUsing Composer with Drupal and Drush
Using Composer with Drupal and DrushPantheon
 
Drupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflowDrupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflowvaluebound
 
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_)
 

Similar a Composer & Drupal (20)

Efficient development workflows with composer
Efficient development workflows with composerEfficient development workflows with composer
Efficient development workflows with composer
 
Efficient development workflows with composer
Efficient development workflows with composerEfficient development workflows with composer
Efficient development workflows with composer
 
Composer
ComposerComposer
Composer
 
Managing your Drupal project with Composer
Managing your Drupal project with ComposerManaging your Drupal project with Composer
Managing your Drupal project with Composer
 
Dependency management with Composer
Dependency management with ComposerDependency management with Composer
Dependency management with Composer
 
Composer JSON kills make files
Composer JSON kills make filesComposer JSON kills make files
Composer JSON kills make files
 
Composer Tools & Frameworks for Drupal
Composer Tools & Frameworks for DrupalComposer Tools & Frameworks for Drupal
Composer Tools & Frameworks for Drupal
 
Composer Best Practices
Composer Best PracticesComposer Best Practices
Composer Best Practices
 
Composer Best Practices
Composer Best PracticesComposer Best Practices
Composer Best Practices
 
Composer Best Practices.pdf
Composer Best Practices.pdfComposer Best Practices.pdf
Composer Best Practices.pdf
 
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)
 
Composer
ComposerComposer
Composer
 
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 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
 
Using Composer with Drupal and Drush
Using Composer with Drupal and DrushUsing Composer with Drupal and Drush
Using Composer with Drupal and Drush
 
Drupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflowDrupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflow
 
Composer namespacing
Composer namespacingComposer namespacing
Composer namespacing
 
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
 

Más de drubb

Barrierefreie Webseiten
Barrierefreie WebseitenBarrierefreie Webseiten
Barrierefreie Webseitendrubb
 
Drupal 9 Entity Bundle Classes
Drupal 9 Entity Bundle ClassesDrupal 9 Entity Bundle Classes
Drupal 9 Entity Bundle Classesdrubb
 
Drupal 8 Dependency Injection Using Traits
Drupal 8 Dependency Injection Using TraitsDrupal 8 Dependency Injection Using Traits
Drupal 8 Dependency Injection Using Traitsdrubb
 
Closing the Drupal Hosting Gap - A Review of Wodby
Closing the Drupal Hosting Gap - A Review of WodbyClosing the Drupal Hosting Gap - A Review of Wodby
Closing the Drupal Hosting Gap - A Review of Wodbydrubb
 
Drupal 8: Theming
Drupal 8: ThemingDrupal 8: Theming
Drupal 8: Themingdrubb
 
Drupal 8: Entities
Drupal 8: EntitiesDrupal 8: Entities
Drupal 8: Entitiesdrubb
 
Drupal 8: Forms
Drupal 8: FormsDrupal 8: Forms
Drupal 8: Formsdrubb
 
Drupal 8: Routing & More
Drupal 8: Routing & MoreDrupal 8: Routing & More
Drupal 8: Routing & Moredrubb
 
Drupal 8 Sample Module
Drupal 8 Sample ModuleDrupal 8 Sample Module
Drupal 8 Sample Moduledrubb
 
Spamschutzverfahren für Drupal
Spamschutzverfahren für DrupalSpamschutzverfahren für Drupal
Spamschutzverfahren für Drupaldrubb
 
Drupal 8: TWIG Template Engine
Drupal 8:  TWIG Template EngineDrupal 8:  TWIG Template Engine
Drupal 8: TWIG Template Enginedrubb
 
Drupal 8: Neuerungen im Überblick
Drupal 8:  Neuerungen im ÜberblickDrupal 8:  Neuerungen im Überblick
Drupal 8: Neuerungen im Überblickdrubb
 
Drupal Entities
Drupal EntitiesDrupal Entities
Drupal Entitiesdrubb
 

Más de drubb (13)

Barrierefreie Webseiten
Barrierefreie WebseitenBarrierefreie Webseiten
Barrierefreie Webseiten
 
Drupal 9 Entity Bundle Classes
Drupal 9 Entity Bundle ClassesDrupal 9 Entity Bundle Classes
Drupal 9 Entity Bundle Classes
 
Drupal 8 Dependency Injection Using Traits
Drupal 8 Dependency Injection Using TraitsDrupal 8 Dependency Injection Using Traits
Drupal 8 Dependency Injection Using Traits
 
Closing the Drupal Hosting Gap - A Review of Wodby
Closing the Drupal Hosting Gap - A Review of WodbyClosing the Drupal Hosting Gap - A Review of Wodby
Closing the Drupal Hosting Gap - A Review of Wodby
 
Drupal 8: Theming
Drupal 8: ThemingDrupal 8: Theming
Drupal 8: Theming
 
Drupal 8: Entities
Drupal 8: EntitiesDrupal 8: Entities
Drupal 8: Entities
 
Drupal 8: Forms
Drupal 8: FormsDrupal 8: Forms
Drupal 8: Forms
 
Drupal 8: Routing & More
Drupal 8: Routing & MoreDrupal 8: Routing & More
Drupal 8: Routing & More
 
Drupal 8 Sample Module
Drupal 8 Sample ModuleDrupal 8 Sample Module
Drupal 8 Sample Module
 
Spamschutzverfahren für Drupal
Spamschutzverfahren für DrupalSpamschutzverfahren für Drupal
Spamschutzverfahren für Drupal
 
Drupal 8: TWIG Template Engine
Drupal 8:  TWIG Template EngineDrupal 8:  TWIG Template Engine
Drupal 8: TWIG Template Engine
 
Drupal 8: Neuerungen im Überblick
Drupal 8:  Neuerungen im ÜberblickDrupal 8:  Neuerungen im Überblick
Drupal 8: Neuerungen im Überblick
 
Drupal Entities
Drupal EntitiesDrupal Entities
Drupal Entities
 

Último

Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirtrahman018755
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Sheetaleventcompany
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)Damian Radcliffe
 
Radiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsRadiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsstephieert
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceDelhi Call girls
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGAPNIC
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girladitipandeya
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebJames Anderson
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...tanu pandey
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Servicegwenoracqe6
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxellan12
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts servicesonalikaur4
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Servicesexy call girls service in goa
 

Último (20)

Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)
 
Radiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsRadiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girls
 
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 6 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Sukhdev Vihar Delhi 💯Call Us 🔝8264348440🔝
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
 
Networking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOGNetworking in the Penumbra presented by Geoff Huston at NZNOG
Networking in the Penumbra presented by Geoff Huston at NZNOG
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
 
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No AdvanceRohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
Rohini Sector 22 Call Girls Delhi 9999965857 @Sabina Saikh No Advance
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
 

Composer & Drupal

  • 1. Composer & Drupal Drupal Meetup Stuttgart 04.02.2016
  • 2. Composer is a... ● Dependency Manager for PHP projects -> Requirements like frameworks or libraries ● Package Manager for PHP packages -> Globally installed tools, like Drush or Console http://getcomposer.org
  • 3. Why should we care? ● Avoiding dependency hell ● Getting off the island ● Don’t reinvent the wheel ● Proudly invented / found elsewhere (PIE) ● Everyone does it ● ~85.000 packages for PHP projects using Composer (2/2016)
  • 4. Basic components composer.json -> Specifies requirements, sources and configuration composer.lock -> Lists installed dependencies with current versions vendor folder -> Dependencies (packages) will be installed here Autoloader -> Makes dependencies available to your project
  • 5. PHP package repository: http://packagist.org
  • 6. What’s a package? Package => ● Script ● Library ● Framework identified by "vendor/package name", e.g. "fabpot/php-cs-fixer"
  • 7. Example composer require andrioli/hello-composer:"@dev" php:">=5.3.0" composer.json: { "require": { "andrioli/hello-composer": "@dev", "php": ">=5.3.0" } } index.php: <?php require 'vendor/autoload.php'; print HelloWorldSay::hello(); Composer defaults to stable versions, here we require dev versions, too!
  • 9. Specify required versions [vendor/package]:[version][@[dev|alpha|beta|RC|stable] Composer supported version constraints: Exact: 7.1.0 -> Exact version Comparison: >=1.2 Range: 1.2 - 1.3 Wildcard: 7.1.* Tilde: ~7.1.3 -> Next significant release, >= 7.1.3, < 7.2 Carét: ^7.1.0 -> Next major release, >= 7.1.0, < 8.0.0
  • 10. One thing to consider “just edit your composer.json and add…” [SeldJsonLintParsingException] "./composer.json" does not contain valid JSON Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them. => Use composer commands!
  • 11. Start a new PHP project: composer init 1. Create your index.php: touch index.php 2. Create composer.json: composer init -n 3. Add requirements/dependencies 4. Add the autoloader to your index.php: require 'vendor/autoload.php';
  • 12. Specify requirements: composer require composer require [ vendor/package ] [ vendor/package ] ... composer require guzzlehttp/guzzle composer require phpunit/phpunit --dev Adds / updates dependencies in composer.json & composer.lock Package only needed for development? Use --dev !
  • 13. Install requirements: composer install composer install composer install --no-dev Installs exact versions specified in composer.lock For production environments, use --no-dev !
  • 14. Update requirements: composer update composer update composer update [ vendor/package ] [ vendor/package ] ... Installs the latest version of the specified packages meeting the requirements in composer.json Updates composer.lock accordingly
  • 15. Remove requirements: composer remove composer remove [ vendor/package ] [ vendor/package ] ... Removes the specified package(s) Removes requirements from composer.json Updates composer.lock accordingly
  • 16. More Composer goodies ● Installs from packagist, various vcs (git, svn, …), pear, zip and more ● Applies patches, if needed ● Supports scripts, e.g. "post-package-install" ● Supports plugins (functional extensions) Some useful plugins: composer/installers -> Scaffolding, type-dependent install folders wikimedia/composer-merge-plugin -> merge multiple composer.json files fxp/composer-asset-plugin -> manage NPM- / Bower packages (CSS/JS)
  • 17. Using composer in Drupal projects Some pitfalls here: ● Semantic versioning: 7.x-3.5, 8.x-4.0 ? ● Different types of packages (modules, themes, libraries) ● Different target folders, not just /vendor ● Dependencies in .info files ● Incompatible project metadata / vcs drupal.org <-> packagist.org Solutions: ● Specialized package repository, packagist.drupal-composer.org ● Use project templates / skeletons!
  • 18. Create a new Drupal project using a template composer create-project drupal-composer/drupal-project:8.x-dev myproject --stability dev --no-interaction composer create-project drupal-composer/drupal-project:7.x-dev myproject -s dev -n https://github.com/drupal-composer/drupal-project (just a starting point) This means the dev version of the template, not of Drupal!
  • 19. It’s not Drupal, it’s best practice! composer create-project symfony/framework-standard-edition composer create-project yiisoft/yii2-app-basic composer create-project laravel/laravel … Use it for scaffolding, profiles, install scripts, configuration, ...
  • 20. Managing Drupal Module & Themes composer require drupal/devel drupal/views composer update drupal/linkit composer remove drupal/webform … Composer takes care of dependencies, so e.g. drupal/views includes drupal/ctools (D7)!
  • 21. What about custom modules? { "name": "drubb/myownmodule”, "description": "Just a little custom module.", "type": "drubb-custom", "homepage": "https://github.com/drubb/myownmodule/" "require": { "drupal/views": ">=7.3.1" }, } Optionally (if not using packagist), use composer-merge plugin to merge your custom composer.json with the main composer.json of your project ! Remember composer-installers?
  • 22. But I use Drush / Console / Bash already? Great! Keep on using them! Additionally use them in your Composer scripts! "post-update-cmd": [ "drush updb", "drush cc all", "echo Updates completed!" ],
  • 23. UI wanted ? Composer Manager Module!
  • 24. Drush Wrapper: Composer Module! drush composer require drush composer install drush composer update … https://drupal.org/project/composer
  • 25. GIT Workflow Development git pull composer install composer require / update git push Add composer.json / composer.lock ! Exclude dependencies (/vendor) ! Default for upcoming Drupal 8.1 ! Production git pull / checkout composer install
  • 26. Read on Official Composer Documentation https://getcomposer.org/doc Composer the Right Way http://www.slideshare.net/rdohms/composer-the-right-way-phpjhb15 Composer Cheat Sheet for Developers http://composer.json.jolicode.com Drupal Composer community initiative http://drupal-composer.org Slides: http://www.slideshare.net/drubb