SlideShare a Scribd company logo
Composer 
the right way 
Rafael Dohms 
@rdohms
photo: smileymanwithahat
Composer the right way
Composer the right way
photo: Rob Allen
The Composer Cookbook 
https://leanpub.com/composer-cookbook
photo: 18millionpixels
Library Publisher 
photo: 18millionpixels
Library Publisher 
Library Consumer 
photo: 18millionpixels
Library Publisher 
Library 
Library Consumer 
photo: 18millionpixels
Library Publisher 
Library 
Packagist 
Library Consumer 
photo: 18millionpixels
photo: 18millionpixels
{ 
"require": { 
"monolog/monolog": “2.0” 
} 
} 
photo: 18millionpixels
{ 
"require": { 
"monolog/monolog": “2.0” 
} 
} 
{ 
"name": “monolog/monolog” 
... 
} 
photo: 18millionpixels
{ 
"require": { 
"monolog/monolog": “2.0” 
} 
} 
{ 
"name": “monolog/monolog” 
... 
} 
./composer.json has been updated 
Loading composer repositories with package information 
Updating dependencies (including require-dev) 
Your requirements could not be resolved to an installable set of packages. 
! 
Problem 1 
- The requested package monolog/monolog could not be found in any version, there may be a typo in the package name. 
! 
Potential causes: 
- A typo in the package name 
- The package is not available in a stable-enough version according to your minimum-stability setting 
see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details. 
! 
Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems. 
! 
Installation failed, reverting ./composer.json to its original content. 
photo: 18millionpixels
{ 
"require": { 
___ 
~1.1 
"monolog/monolog": “2.0” 
} 
} 
{ 
"name": “monolog/monolog” 
... 
} 
./composer.json has been updated 
Loading composer repositories with package information 
Updating dependencies (including require-dev) 
Your requirements could not be resolved to an installable set of packages. 
! 
Problem 1 
- The requested package monolog/monolog could not be found in any version, there may be a typo in the package name. 
! 
Potential causes: 
- A typo in the package name 
- The package is not available in a stable-enough version according to your minimum-stability setting 
see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details. 
! 
Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems. 
! 
Installation failed, reverting ./composer.json to its original content. 
photo: 18millionpixels
{ 
"require": { 
___ 
~1.1 
"monolog/monolog": “2.0” 
} 
} 
{ 
"name": “monolog/monolog” 
... 
} 
./composer.json has been updated 
Loading composer repositories with package information 
Updating dependencies (including require-dev) 
Your requirements could not be resolved to an installable set of packages. 
! 
Problem 1 
- Installing psr/log (1.0.0) 
Loading from cache 
! 
- Installing monolog/monolog (1.11.0) 
- The requested package monolog/monolog could not be found in any version, there may be a typo in the package name. 
! 
Downloading: 100% 
Potential causes: 
- A typo in the package name 
- The package is not available in a stable-enough version according to your minimum-stability setting 
! 
monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server) 
[...] 
monolog/see <https://monolog groups.suggests google.installing com/d/ext-topic/mongo composer-(Allow dev/_sending g3ASeIFlrc/log messages discussion> to a for MongoDB more server) 
details. 
monolog/! 
monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB) 
monolog/Read <http://monolog getcomposer.suggests org/installing doc/articles/rollbar/troubleshooting.rollbar (Allow md> sending for further log messages common to problems. 
Rollbar) 
! 
Writing lock file 
Installation Generating autoload failed, files 
reverting ./composer.json to its original content. 
photo: 18millionpixels
composer
! composer.json composer
! composer.json composer 
! composer.lock
! composer.json composer 
! composer.lock
discovery Packagist 
" 
! composer.json composer 
! composer.lock
discovery Packagist source 
" 
Repository 
# 
! composer.json composer 
! composer.lock
discovery source 
installation 
Packagist 
" 
Vendor 
Folder 
$ 
Repository 
# 
! composer.json composer 
! composer.lock
Library Publisher 
$ composer init
Library Publisher 
$ composer init 
Library Consumer 
$ composer require <vendor>/<package>
Tip 
$ composer require monolog/monolog 
Using version ~1.11 for monolog/monolog
Composer for 
Library Publishers
vendor / package 
Library Publisher Unique vendor names
pick your own 
unique vendor 
Library Publisher Unique vendor names
or join a collective 
Library Publisher Unique vendor names
! README 
% CHANGELOG 
& LICENSE 
Library Publisher What’s in your library?
! README 
% CHANGELOG 
& LICENSE 
' What problem does it solve? 
' Usage examples 
' Install instructions 
' How can I contribute? 
Library Publisher What’s in your library?
! README 
% CHANGELOG 
& LICENSE 
' What problem does it solve? 
' Usage examples 
' Install instructions 
' How can I contribute? 
' List relevant changes 
' Make BC breaks prominent 
' Show examples of how to upgrade 
Library Publisher What’s in your library?
! README 
% CHANGELOG 
& LICENSE 
' What problem does it solve? 
' Usage examples 
' Install instructions 
' How can I contribute? 
' List relevant changes 
' Make BC breaks prominent 
' Show examples of how to upgrade 
' Pick one that reflects your values 
' choosealicense.com can help 
Library Publisher What’s in your library?
1 . 2 . 3 
major minor patch 
Library Publisher Semantic Versioning
1 . 2 . 3 
major minor patch 
Library Publisher Semantic Versioning 
Bug Fixes
New Features Bug Fixes 
1 . 2 . 3 
major minor patch 
Library Publisher Semantic Versioning
API / BC Breaks New Features Bug Fixes 
1 . 2 . 3 
major minor patch 
Library Publisher Semantic Versioning
Tag it and Bag it 
Library Publisher Tagging
# Simple Tag 
$ git tag v1.2.3 
! 
! 
! 
# Annotated Tag 
$ git tag -a v1.2.3 -m “Description of Release" 
Library Publisher Tagging
Library Publisher “I'm out" 
photo: jilliancorinne
Library Publisher “I'm out"
Click here and provide another 
Library Publisher “I'm out"
Library Publisher “I'm out"
Library Publisher “I'm out" 
coming 
soon
Pick the 
correct 
version 
Library Publisher Pick a Version
* the asterisk 
Library Publisher Pick a Version
* the asterisk ○ 
Library Publisher Pick a Version
~ the tilde 
Library Publisher Pick a Version
~1.2 
>=1.2.0, <2.0.0 
Library Publisher Pick a Version
~1.2 
>=1.2.0, <2.0.0 
Library Publisher Pick a Version 
)
~1.2.3 
>=1.2.0, <1.3 
Library Publisher Pick a Version
~1.2.3 
>=1.2.0, <1.3 
Library Publisher Pick a Version 
)
3rd party library 
"require": { 
"zendframework/zend-stdlib": “2.1.*”, 
"zendframework/zend-servicemanager": "2.1.*", 
}, 
! 
“require-dev": { 
“phpunit/phpunit": “~3.7” 
} 
Your application 
"require": { 
"zendframework/zend-stdlib": “~2.3”, 
"zendframework/zend-servicemanager": “~2.3", 
}, 
! 
“require-dev": { 
“phpunit/phpunit": “~4” 
} 
Library Publisher Pick a Version
3rd party library 
"require": { 
"zendframework/zend-stdlib": “2.1.*”, 
"zendframework/zend-servicemanager": "2.1.*", 
}, 
! 
“require-dev": { 
* 
“phpunit/phpunit": “~3.7” 
} 
Your application 
"require": { 
"zendframework/zend-stdlib": “~2.3”, 
"zendframework/zend-servicemanager": “~2.3", 
}, 
! 
“require-dev": { 
“phpunit/phpunit": “~4” 
} 
Library Publisher Pick a Version
3rd party library 
"require": { 
"zendframework/zend-stdlib": “2.1.*”, 
"zendframework/zend-servicemanager": "2.1.*", 
}, 
! 
“require-dev": { 
* 
“phpunit/phpunit": “~3.7” 
} 
Your application 
"require": { 
"zendframework/zend-stdlib": “~2.3”, 
"zendframework/zend-servicemanager": “~2.3", 
}, 
! 
“require-dev": { 
“phpunit/phpunit": “~4” 
} 
Library Publisher Pick a Version
3rd party library 
"require": { 
"zendframework/zend-stdlib": “2.1.*”, 
"zendframework/zend-servicemanager": "2.1.*", 
}, 
! 
“require-dev": { 
* 
“phpunit/phpunit": “~3.7” 
} 
Your application 
"require": { 
"zendframework/zend-stdlib": “~2.3”, 
"zendframework/zend-servicemanager": “~2.3", 
}, 
! 
“require-dev": { 
“phpunit/phpunit": “~4” 
} 
Library Publisher Pick a Version 
~2.1
Composer for 
Library Consumers
install or update? 
Library Consumer Install or update?
Make sure you have 
installed the last 
updates from other 
developers. 
? 
install or update 
Library Consumer Install or update?
Make sure you have 
installed the last 
updates from other 
developers. 
? 
install or update 
Library Consumer Install or update?
Deploying a new 
release of your 
application to 
production. 
? 
install or update 
Library Consumer Install or update?
Deploying a new 
release of your 
application to 
production. 
? 
install or update 
Library Consumer Install or update?
Checked out a new 
project and want to 
start coding. 
? 
install or update 
Library Consumer Install or update?
Checked out a new 
project and want to 
start coding. 
? 
install or update 
Library Consumer Install or update?
Grab new versions for 
the dependencies of 
your project. 
? 
install or update 
Library Consumer Install or update?
Grab new versions for 
the dependencies of 
your project. 
? 
install or update 
Library Consumer Install or update?
Your application 
$ 
Public 
Repository 
# 
! composer.lock 
composer install 
composer update 
Library Consumer Install or update?
Your application 
$ 
Public 
Repository 
# 
! composer.lock 
read 
composer install 
composer update 
Library Consumer Install or update?
Your application 
$ 
read grab version 
Public 
Repository 
# 
! composer.lock 
composer install 
composer update 
Library Consumer Install or update?
Your application 
$ 
read grab version 
Public 
Repository 
# 
! composer.lock 
check latest compatible release 
composer install 
composer update 
Library Consumer Install or update?
Your application 
$ 
read grab version 
Public 
Repository 
# 
! composer.lock 
check latest compatible release 
Library Consumer Install or update? 
update 
composer install 
composer update
commit your lock file 
Library Consumer Install or update?
Tip 
$ composer update --lock 
Library Consumer Install or update?
Pick the 
correct 
version 
Library Consumer Version Selection
dev-master 
Library Consumer Version Selection
Library Consumer Version Selection
Library Consumer Version Selection
found a bug? 
Library Consumer Using forks
Tip 
$ composer install --prefer-source 
Library Consumer Using forks
Library Consumer Using forks
patch it, 
Library Consumer Using forks
patch it, 
fork it, 
Library Consumer Using forks
patch it, 
fork it, 
push it… 
Library Consumer Using forks
patch it, 
fork it, 
push it… 
wait for it. 
Library Consumer Using forks
patch it, 
fork it, 
push it… 
wait for it. 
Library Consumer Using forks
symfony/symfony 
Library Consumer Using forks
symfony/symfony 
Library Consumer Using forks 
rdohms/symfony
symfony/symfony 
Library Consumer Using forks 
rdohms/symfony 
"repositories": [ 
{ 
"type": "vcs", 
"url": "https://github.com/rdohms/symfony" 
} 
]
symfony/symfony 
Library Consumer Using forks 
rdohms/symfony 
"repositories": [ 
{ 
"type": "vcs", 
"url": "https://github.com/rdohms/symfony" 
} 
] 
+
Tip 
$ composer show -v symfony/symfony 
Library Consumer Using forks
Do not put 
forked repositories 
on packagist 
, 
Library Consumer Using forks
Tip 
"require": { 
"symfony/symfony": "dev-my-patch as 2.5.0" 
} 
Library Consumer Using forks
Composer 
and 
production 
Library Consumer Composer and deployments
Packagist 
. 
Production 
Server 
- 
Library Consumer Composer and deployments
Packagist 
. 
/ Man in the middle 
Production 
Server 
- 
Library Consumer Composer and deployments
Build Server 
0 
Library Consumer Composer and deployments 
Production 
Server 
- 
" 
Packagist 
. 
/ Man in the middle
, 
$ composer install --prefer-dist --no-dev —optimize-autoloader 
Library Consumer Composer and deployments
, 
$ composer install --prefer-dist --no-dev —optimize-autoloader 
Library Consumer Composer and deployments
, 
$ composer install --prefer-dist --no-dev —optimize-autoloader 
1 Install same versions 
1 Uses information defined in the composer.lock file 
Library Consumer Composer and deployments
, 
$ composer install --prefer-dist --no-dev —optimize-autoloader 
Library Consumer Composer and deployments
, 
$ composer install --prefer-dist --no-dev —optimize-autoloader 
1 Downloads distribution packages 
1 Can use local cache for previously downloaded 
1 No git required 
Library Consumer Composer and deployments
, 
$ composer install --prefer-dist --no-dev —optimize-autoloader 
Library Consumer Composer and deployments
, 
$ composer install --prefer-dist --no-dev —optimize-autoloader 
1 Avoids download unnecessary developer libraries 
Library Consumer Composer and deployments
, 
$ composer install --prefer-dist --no-dev —optimize-autoloader 
Library Consumer Composer and deployments
, 
$ composer install --prefer-dist --no-dev —optimize-autoloader 
1 Generates classmap from PSR-0/4 autoloaders 
1 Speeds up autoloading 
Library Consumer Composer and deployments
Tip 
$ composer licenses 
! 
Name: __root__ 
Version: 1.0.0 
Licenses: none 
Dependencies: 
! 
doctrine/annotations v1.2.1 MIT 
doctrine/cache v1.3.1 MIT 
doctrine/collections v1.2 MIT 
doctrine/common v2.4.2 MIT 
doctrine/inflector v1.0 MIT 
doctrine/lexer v1.0 MIT 
psr/log 1.0.0 MIT 
symfony/symfony v2.5.6 MIT 
twig/twig v1.16.2 BSD-3-Clause 
Library Consumer Licensing
Satis and Toran 
Library Consumer Private Packages and Proxy
composer Packagist 
" 
Your application 
$ 
Public 
Repository 
# 
Library Consumer Private Packages and Proxy
composer 
Packagist 
" 
Your application 
$ 
Public 
Repository 
# 
Satis / Toran 
" 
Private 
Repository 
2 
proxy 
Library Consumer Private Packages and Proxy
toranproxy.com 
private repos, automatic packagist proxy 
and support composer development 
Library Consumer Private Packages and Proxy
How many of you? 
$ composer require jquery/jquery 
Library Consumer Tooling
Library Consumer Tooling
Library Consumer Tooling
Javascript only Developer 
3 my-js-library 
4 
Library Consumer Tooling
Javascript only Developer 
3 my-js-library 
Library Consumer Tooling 
! package.json 
4
Javascript only Developer 
3 my-js-library 
Library Consumer Tooling 
! package.json 
! bower.json 
4
Javascript only Developer 
3 my-js-library 
Library Consumer Tooling 
! package.json 
! bower.json 
! composer.json 
4
Javascript only Developer 
3 my-js-library 
Library Consumer Tooling 
! package.json 
! bower.json 
! composer.json 
! .gemspec 
4
Javascript only Developer 
3 my-js-library 
Library Consumer Tooling 
! package.json 
! bower.json 
! composer.json 
! .gemspec 
4 
/ 
/
Library Consumer Tooling
Right tool. 
Right job. 
Library Consumer Tooling
One last thing… 
Library Consumer One last thing
Library Consumer pickle!
$ pickle install memcache 
https://wiki.php.net/rfc/pickle 
https://github.com/FriendsOfPHP/pickle 
Library Consumer pickle!
https://joind.in/11878 
Thank you.
https://joind.in/11878 
Thank you. any questions? 
7 @rdohms 
6 http://doh.ms 
5 http://slides.doh.ms

More Related Content

PDF
Composer The Right Way #PHPjhb15
PDF
Composer The Right Way - PHPUGMRN
PDF
Composer the Right Way - PHPSRB16
PDF
Composer the Right Way - MM16NL
PDF
Composer the Right Way - PHPBNL16
PDF
Composer The Right Way - 010PHP
PDF
Composer the right way - DPC15
PDF
Composer The Right Way
Composer The Right Way #PHPjhb15
Composer The Right Way - PHPUGMRN
Composer the Right Way - PHPSRB16
Composer the Right Way - MM16NL
Composer the Right Way - PHPBNL16
Composer The Right Way - 010PHP
Composer the right way - DPC15
Composer The Right Way

What's hot (20)

PDF
Composer the right way - NomadPHP
PDF
Composer the right way [SweetlakePHP]
PDF
Composer for Busy Developers - php|tek13
PDF
Composer the right way - SunshinePHP
PDF
Dependency management with Composer
PPTX
PHP Dependency Management with Composer
PDF
Dependency Management with Composer
PPTX
Php psr standard 2014 01-22
PDF
Mastering Maven 2.0 In 1 Hour V1.3
PDF
Asynchronous Systems with Fn Flow
PDF
Swoole Love PHP
ODP
Packaging for the Maemo Platform
ODP
The Gory Details of Debian packages
PDF
Lecture1: NGS Analysis on Beocat and an introduction to Perl programming for ...
PDF
CMake Tutorial
KEY
Dependency Management With Pinto
KEY
Pinto+Stratopan+Love
PPT
Solbase & Real-time Activity
PDF
Effective CMake
Composer the right way - NomadPHP
Composer the right way [SweetlakePHP]
Composer for Busy Developers - php|tek13
Composer the right way - SunshinePHP
Dependency management with Composer
PHP Dependency Management with Composer
Dependency Management with Composer
Php psr standard 2014 01-22
Mastering Maven 2.0 In 1 Hour V1.3
Asynchronous Systems with Fn Flow
Swoole Love PHP
Packaging for the Maemo Platform
The Gory Details of Debian packages
Lecture1: NGS Analysis on Beocat and an introduction to Perl programming for ...
CMake Tutorial
Dependency Management With Pinto
Pinto+Stratopan+Love
Solbase & Real-time Activity
Effective CMake
Ad

Viewers also liked (20)

PDF
Understanding Engineers
PDF
Composer: putting dependencies on the score
PDF
Composting Institutional Food Scraps with Worms
PPTX
Bay mulchshowcase
PPTX
Innovations in composting
PPT
Schools#2 Cafeteria Composting Programs - Cambridge
PDF
How to be a SemVer Hero – an interactive lightning talk
PDF
Andy carvell-sound cloud
PPT
Los Coches Del Papa
PDF
Semantic Versioning
PPTX
2015 ISOSWO APWA Spring Conference: Composting at Landfills
PPT
Food Waste Composting - Montgomery County - Opportunities and Obstacles April...
PPTX
Semantic Versioning Lightning Talk
PPT
PDF
Wearable - storytelling or storydoing - Yiannis Lapatas
PPTX
The Rise of Wearable Technology
PDF
Engineering your culture how to keep your engineers happy
PPTX
3D print for manufacturing
PDF
Жизнь в спектре аутизма и за его пределами
PDF
Liferay + Wearables
Understanding Engineers
Composer: putting dependencies on the score
Composting Institutional Food Scraps with Worms
Bay mulchshowcase
Innovations in composting
Schools#2 Cafeteria Composting Programs - Cambridge
How to be a SemVer Hero – an interactive lightning talk
Andy carvell-sound cloud
Los Coches Del Papa
Semantic Versioning
2015 ISOSWO APWA Spring Conference: Composting at Landfills
Food Waste Composting - Montgomery County - Opportunities and Obstacles April...
Semantic Versioning Lightning Talk
Wearable - storytelling or storydoing - Yiannis Lapatas
The Rise of Wearable Technology
Engineering your culture how to keep your engineers happy
3D print for manufacturing
Жизнь в спектре аутизма и за его пределами
Liferay + Wearables
Ad

Similar to Composer the right way (20)

PDF
Game Changing Dependency Management
PDF
Composer - The missing package manager for PHP
PDF
Beginning with Composer - Dependency manager in php
PDF
Composer Best Practices
PDF
Composer Best Practices.pdf
PDF
Composer Best Practices
PPTX
Nh php may 2014 - composer
PDF
Leveraging Composer in Existing Projects
PDF
12 Composer #burningkeyboards
PDF
composer_talk_20160209
PDF
Shifting gears with Composer
PDF
Composer yourself: a reintroduction to composer
PDF
Create a PHP Library the right way
PDF
Php Dependency Management with Composer ZendCon 2016
PDF
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
PDF
Php Dependency Management with Composer ZendCon 2017
PDF
Composer for busy developers - DPC13
KEY
Composer
PDF
Composer Helpdesk
Game Changing Dependency Management
Composer - The missing package manager for PHP
Beginning with Composer - Dependency manager in php
Composer Best Practices
Composer Best Practices.pdf
Composer Best Practices
Nh php may 2014 - composer
Leveraging Composer in Existing Projects
12 Composer #burningkeyboards
composer_talk_20160209
Shifting gears with Composer
Composer yourself: a reintroduction to composer
Create a PHP Library the right way
Php Dependency Management with Composer ZendCon 2016
Packaging the Monolith - PHP Tek 2024 (Breaking it down one bite at a time)
Php Dependency Management with Composer ZendCon 2017
Composer for busy developers - DPC13
Composer
Composer Helpdesk

More from Rafael Dohms (20)

PDF
The Individual Contributor Path - DPC2024
PDF
Application Metrics - IPC2023
PDF
How'd we get here? A guide to Architectural Decision Records
PDF
Architectural Decision Records - PHPConfBR
PDF
Application Metrics (with Prometheus examples)
PDF
Application metrics - Confoo 2019
PDF
Writing code you won’t hate tomorrow - PHPCE18
PDF
Application Metrics (with Prometheus examples) #PHPDD18
PDF
Application metrics with Prometheus - DPC18
PDF
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf
PDF
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...
PDF
Writing Code That Lasts - #Magento2Seminar, Utrecht
PDF
“Writing code that lasts” … or writing code you won’t hate tomorrow. - #PHPSRB16
PDF
“Writing code that lasts” … or writing code you won’t hate tomorrow.
PDF
A Journey into your Lizard Brain - PHP Conference Brasil 2015
PDF
“Writing code that lasts” … or writing code you won’t hate tomorrow.
PDF
“Writing code that lasts” … or writing code you won’t hate tomorrow.
PDF
“Writing code that lasts” … or writing code you won’t hate tomorrow.
PDF
Journey into your Lizard Brain - PHPJHB15
PDF
A journey into your Lizard Brain
The Individual Contributor Path - DPC2024
Application Metrics - IPC2023
How'd we get here? A guide to Architectural Decision Records
Architectural Decision Records - PHPConfBR
Application Metrics (with Prometheus examples)
Application metrics - Confoo 2019
Writing code you won’t hate tomorrow - PHPCE18
Application Metrics (with Prometheus examples) #PHPDD18
Application metrics with Prometheus - DPC18
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...
Writing Code That Lasts - #Magento2Seminar, Utrecht
“Writing code that lasts” … or writing code you won’t hate tomorrow. - #PHPSRB16
“Writing code that lasts” … or writing code you won’t hate tomorrow.
A Journey into your Lizard Brain - PHP Conference Brasil 2015
“Writing code that lasts” … or writing code you won’t hate tomorrow.
“Writing code that lasts” … or writing code you won’t hate tomorrow.
“Writing code that lasts” … or writing code you won’t hate tomorrow.
Journey into your Lizard Brain - PHPJHB15
A journey into your Lizard Brain

Recently uploaded (20)

PPTX
Sustainable Sites - Green Building Construction
PPTX
web development for engineering and engineering
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
Structs to JSON How Go Powers REST APIs.pdf
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PDF
composite construction of structures.pdf
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPT
Project quality management in manufacturing
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
additive manufacturing of ss316l using mig welding
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
DOCX
573137875-Attendance-Management-System-original
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
Lecture Notes Electrical Wiring System Components
Sustainable Sites - Green Building Construction
web development for engineering and engineering
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Internet of Things (IOT) - A guide to understanding
Structs to JSON How Go Powers REST APIs.pdf
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
composite construction of structures.pdf
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Project quality management in manufacturing
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Strings in CPP - Strings in C++ are sequences of characters used to store and...
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
additive manufacturing of ss316l using mig welding
Operating System & Kernel Study Guide-1 - converted.pdf
573137875-Attendance-Management-System-original
Lesson 3_Tessellation.pptx finite Mathematics
OOP with Java - Java Introduction (Basics)
Lecture Notes Electrical Wiring System Components

Composer the right way

  • 1. Composer the right way Rafael Dohms @rdohms
  • 6. The Composer Cookbook https://leanpub.com/composer-cookbook
  • 8. Library Publisher photo: 18millionpixels
  • 9. Library Publisher Library Consumer photo: 18millionpixels
  • 10. Library Publisher Library Library Consumer photo: 18millionpixels
  • 11. Library Publisher Library Packagist Library Consumer photo: 18millionpixels
  • 13. { "require": { "monolog/monolog": “2.0” } } photo: 18millionpixels
  • 14. { "require": { "monolog/monolog": “2.0” } } { "name": “monolog/monolog” ... } photo: 18millionpixels
  • 15. { "require": { "monolog/monolog": “2.0” } } { "name": “monolog/monolog” ... } ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages. ! Problem 1 - The requested package monolog/monolog could not be found in any version, there may be a typo in the package name. ! Potential causes: - A typo in the package name - The package is not available in a stable-enough version according to your minimum-stability setting see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details. ! Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems. ! Installation failed, reverting ./composer.json to its original content. photo: 18millionpixels
  • 16. { "require": { ___ ~1.1 "monolog/monolog": “2.0” } } { "name": “monolog/monolog” ... } ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages. ! Problem 1 - The requested package monolog/monolog could not be found in any version, there may be a typo in the package name. ! Potential causes: - A typo in the package name - The package is not available in a stable-enough version according to your minimum-stability setting see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details. ! Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems. ! Installation failed, reverting ./composer.json to its original content. photo: 18millionpixels
  • 17. { "require": { ___ ~1.1 "monolog/monolog": “2.0” } } { "name": “monolog/monolog” ... } ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages. ! Problem 1 - Installing psr/log (1.0.0) Loading from cache ! - Installing monolog/monolog (1.11.0) - The requested package monolog/monolog could not be found in any version, there may be a typo in the package name. ! Downloading: 100% Potential causes: - A typo in the package name - The package is not available in a stable-enough version according to your minimum-stability setting ! monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server) [...] monolog/see <https://monolog groups.suggests google.installing com/d/ext-topic/mongo composer-(Allow dev/_sending g3ASeIFlrc/log messages discussion> to a for MongoDB more server) details. monolog/! monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB) monolog/Read <http://monolog getcomposer.suggests org/installing doc/articles/rollbar/troubleshooting.rollbar (Allow md> sending for further log messages common to problems. Rollbar) ! Writing lock file Installation Generating autoload failed, files reverting ./composer.json to its original content. photo: 18millionpixels
  • 20. ! composer.json composer ! composer.lock
  • 21. ! composer.json composer ! composer.lock
  • 22. discovery Packagist " ! composer.json composer ! composer.lock
  • 23. discovery Packagist source " Repository # ! composer.json composer ! composer.lock
  • 24. discovery source installation Packagist " Vendor Folder $ Repository # ! composer.json composer ! composer.lock
  • 25. Library Publisher $ composer init
  • 26. Library Publisher $ composer init Library Consumer $ composer require <vendor>/<package>
  • 27. Tip $ composer require monolog/monolog Using version ~1.11 for monolog/monolog
  • 28. Composer for Library Publishers
  • 29. vendor / package Library Publisher Unique vendor names
  • 30. pick your own unique vendor Library Publisher Unique vendor names
  • 31. or join a collective Library Publisher Unique vendor names
  • 32. ! README % CHANGELOG & LICENSE Library Publisher What’s in your library?
  • 33. ! README % CHANGELOG & LICENSE ' What problem does it solve? ' Usage examples ' Install instructions ' How can I contribute? Library Publisher What’s in your library?
  • 34. ! README % CHANGELOG & LICENSE ' What problem does it solve? ' Usage examples ' Install instructions ' How can I contribute? ' List relevant changes ' Make BC breaks prominent ' Show examples of how to upgrade Library Publisher What’s in your library?
  • 35. ! README % CHANGELOG & LICENSE ' What problem does it solve? ' Usage examples ' Install instructions ' How can I contribute? ' List relevant changes ' Make BC breaks prominent ' Show examples of how to upgrade ' Pick one that reflects your values ' choosealicense.com can help Library Publisher What’s in your library?
  • 36. 1 . 2 . 3 major minor patch Library Publisher Semantic Versioning
  • 37. 1 . 2 . 3 major minor patch Library Publisher Semantic Versioning Bug Fixes
  • 38. New Features Bug Fixes 1 . 2 . 3 major minor patch Library Publisher Semantic Versioning
  • 39. API / BC Breaks New Features Bug Fixes 1 . 2 . 3 major minor patch Library Publisher Semantic Versioning
  • 40. Tag it and Bag it Library Publisher Tagging
  • 41. # Simple Tag $ git tag v1.2.3 ! ! ! # Annotated Tag $ git tag -a v1.2.3 -m “Description of Release" Library Publisher Tagging
  • 42. Library Publisher “I'm out" photo: jilliancorinne
  • 44. Click here and provide another Library Publisher “I'm out"
  • 46. Library Publisher “I'm out" coming soon
  • 47. Pick the correct version Library Publisher Pick a Version
  • 48. * the asterisk Library Publisher Pick a Version
  • 49. * the asterisk ○ Library Publisher Pick a Version
  • 50. ~ the tilde Library Publisher Pick a Version
  • 51. ~1.2 >=1.2.0, <2.0.0 Library Publisher Pick a Version
  • 52. ~1.2 >=1.2.0, <2.0.0 Library Publisher Pick a Version )
  • 53. ~1.2.3 >=1.2.0, <1.3 Library Publisher Pick a Version
  • 54. ~1.2.3 >=1.2.0, <1.3 Library Publisher Pick a Version )
  • 55. 3rd party library "require": { "zendframework/zend-stdlib": “2.1.*”, "zendframework/zend-servicemanager": "2.1.*", }, ! “require-dev": { “phpunit/phpunit": “~3.7” } Your application "require": { "zendframework/zend-stdlib": “~2.3”, "zendframework/zend-servicemanager": “~2.3", }, ! “require-dev": { “phpunit/phpunit": “~4” } Library Publisher Pick a Version
  • 56. 3rd party library "require": { "zendframework/zend-stdlib": “2.1.*”, "zendframework/zend-servicemanager": "2.1.*", }, ! “require-dev": { * “phpunit/phpunit": “~3.7” } Your application "require": { "zendframework/zend-stdlib": “~2.3”, "zendframework/zend-servicemanager": “~2.3", }, ! “require-dev": { “phpunit/phpunit": “~4” } Library Publisher Pick a Version
  • 57. 3rd party library "require": { "zendframework/zend-stdlib": “2.1.*”, "zendframework/zend-servicemanager": "2.1.*", }, ! “require-dev": { * “phpunit/phpunit": “~3.7” } Your application "require": { "zendframework/zend-stdlib": “~2.3”, "zendframework/zend-servicemanager": “~2.3", }, ! “require-dev": { “phpunit/phpunit": “~4” } Library Publisher Pick a Version
  • 58. 3rd party library "require": { "zendframework/zend-stdlib": “2.1.*”, "zendframework/zend-servicemanager": "2.1.*", }, ! “require-dev": { * “phpunit/phpunit": “~3.7” } Your application "require": { "zendframework/zend-stdlib": “~2.3”, "zendframework/zend-servicemanager": “~2.3", }, ! “require-dev": { “phpunit/phpunit": “~4” } Library Publisher Pick a Version ~2.1
  • 59. Composer for Library Consumers
  • 60. install or update? Library Consumer Install or update?
  • 61. Make sure you have installed the last updates from other developers. ? install or update Library Consumer Install or update?
  • 62. Make sure you have installed the last updates from other developers. ? install or update Library Consumer Install or update?
  • 63. Deploying a new release of your application to production. ? install or update Library Consumer Install or update?
  • 64. Deploying a new release of your application to production. ? install or update Library Consumer Install or update?
  • 65. Checked out a new project and want to start coding. ? install or update Library Consumer Install or update?
  • 66. Checked out a new project and want to start coding. ? install or update Library Consumer Install or update?
  • 67. Grab new versions for the dependencies of your project. ? install or update Library Consumer Install or update?
  • 68. Grab new versions for the dependencies of your project. ? install or update Library Consumer Install or update?
  • 69. Your application $ Public Repository # ! composer.lock composer install composer update Library Consumer Install or update?
  • 70. Your application $ Public Repository # ! composer.lock read composer install composer update Library Consumer Install or update?
  • 71. Your application $ read grab version Public Repository # ! composer.lock composer install composer update Library Consumer Install or update?
  • 72. Your application $ read grab version Public Repository # ! composer.lock check latest compatible release composer install composer update Library Consumer Install or update?
  • 73. Your application $ read grab version Public Repository # ! composer.lock check latest compatible release Library Consumer Install or update? update composer install composer update
  • 74. commit your lock file Library Consumer Install or update?
  • 75. Tip $ composer update --lock Library Consumer Install or update?
  • 76. Pick the correct version Library Consumer Version Selection
  • 77. dev-master Library Consumer Version Selection
  • 80. found a bug? Library Consumer Using forks
  • 81. Tip $ composer install --prefer-source Library Consumer Using forks
  • 83. patch it, Library Consumer Using forks
  • 84. patch it, fork it, Library Consumer Using forks
  • 85. patch it, fork it, push it… Library Consumer Using forks
  • 86. patch it, fork it, push it… wait for it. Library Consumer Using forks
  • 87. patch it, fork it, push it… wait for it. Library Consumer Using forks
  • 89. symfony/symfony Library Consumer Using forks rdohms/symfony
  • 90. symfony/symfony Library Consumer Using forks rdohms/symfony "repositories": [ { "type": "vcs", "url": "https://github.com/rdohms/symfony" } ]
  • 91. symfony/symfony Library Consumer Using forks rdohms/symfony "repositories": [ { "type": "vcs", "url": "https://github.com/rdohms/symfony" } ] +
  • 92. Tip $ composer show -v symfony/symfony Library Consumer Using forks
  • 93. Do not put forked repositories on packagist , Library Consumer Using forks
  • 94. Tip "require": { "symfony/symfony": "dev-my-patch as 2.5.0" } Library Consumer Using forks
  • 95. Composer and production Library Consumer Composer and deployments
  • 96. Packagist . Production Server - Library Consumer Composer and deployments
  • 97. Packagist . / Man in the middle Production Server - Library Consumer Composer and deployments
  • 98. Build Server 0 Library Consumer Composer and deployments Production Server - " Packagist . / Man in the middle
  • 99. , $ composer install --prefer-dist --no-dev —optimize-autoloader Library Consumer Composer and deployments
  • 100. , $ composer install --prefer-dist --no-dev —optimize-autoloader Library Consumer Composer and deployments
  • 101. , $ composer install --prefer-dist --no-dev —optimize-autoloader 1 Install same versions 1 Uses information defined in the composer.lock file Library Consumer Composer and deployments
  • 102. , $ composer install --prefer-dist --no-dev —optimize-autoloader Library Consumer Composer and deployments
  • 103. , $ composer install --prefer-dist --no-dev —optimize-autoloader 1 Downloads distribution packages 1 Can use local cache for previously downloaded 1 No git required Library Consumer Composer and deployments
  • 104. , $ composer install --prefer-dist --no-dev —optimize-autoloader Library Consumer Composer and deployments
  • 105. , $ composer install --prefer-dist --no-dev —optimize-autoloader 1 Avoids download unnecessary developer libraries Library Consumer Composer and deployments
  • 106. , $ composer install --prefer-dist --no-dev —optimize-autoloader Library Consumer Composer and deployments
  • 107. , $ composer install --prefer-dist --no-dev —optimize-autoloader 1 Generates classmap from PSR-0/4 autoloaders 1 Speeds up autoloading Library Consumer Composer and deployments
  • 108. Tip $ composer licenses ! Name: __root__ Version: 1.0.0 Licenses: none Dependencies: ! doctrine/annotations v1.2.1 MIT doctrine/cache v1.3.1 MIT doctrine/collections v1.2 MIT doctrine/common v2.4.2 MIT doctrine/inflector v1.0 MIT doctrine/lexer v1.0 MIT psr/log 1.0.0 MIT symfony/symfony v2.5.6 MIT twig/twig v1.16.2 BSD-3-Clause Library Consumer Licensing
  • 109. Satis and Toran Library Consumer Private Packages and Proxy
  • 110. composer Packagist " Your application $ Public Repository # Library Consumer Private Packages and Proxy
  • 111. composer Packagist " Your application $ Public Repository # Satis / Toran " Private Repository 2 proxy Library Consumer Private Packages and Proxy
  • 112. toranproxy.com private repos, automatic packagist proxy and support composer development Library Consumer Private Packages and Proxy
  • 113. How many of you? $ composer require jquery/jquery Library Consumer Tooling
  • 116. Javascript only Developer 3 my-js-library 4 Library Consumer Tooling
  • 117. Javascript only Developer 3 my-js-library Library Consumer Tooling ! package.json 4
  • 118. Javascript only Developer 3 my-js-library Library Consumer Tooling ! package.json ! bower.json 4
  • 119. Javascript only Developer 3 my-js-library Library Consumer Tooling ! package.json ! bower.json ! composer.json 4
  • 120. Javascript only Developer 3 my-js-library Library Consumer Tooling ! package.json ! bower.json ! composer.json ! .gemspec 4
  • 121. Javascript only Developer 3 my-js-library Library Consumer Tooling ! package.json ! bower.json ! composer.json ! .gemspec 4 / /
  • 123. Right tool. Right job. Library Consumer Tooling
  • 124. One last thing… Library Consumer One last thing
  • 126. $ pickle install memcache https://wiki.php.net/rfc/pickle https://github.com/FriendsOfPHP/pickle Library Consumer pickle!
  • 128. https://joind.in/11878 Thank you. any questions? 7 @rdohms 6 http://doh.ms 5 http://slides.doh.ms