SlideShare a Scribd company logo
Mastering Composer
Adán Lobato
What’s up!

•

Soy Adán Lobato


•

Soy de Barcelona


•

Soy software developer


•

Backend Developer en SocialPoint


•

Mi twitter es @adanlobato
Agenda
•

Minimum stability


•

Branch aliases


•

Semantic versioning


•

Private Repositories


•

Installers


•

Embedded Composer


•

Useful links
Parental Advisory
Minimum stability
Minimum stability, the problem
Minimum stability exposed

Stable!
RC
“minimum-stability”:

Beta
Alpha
Dev

@stable
@rc
@beta
@alpha
@dev
minimum-stability, the global solution
{
"require": {
"php": ">=5.3.3",
"symfony/icu": "~1.0",
"doctrine/common": "~2.2",
"twig/twig": "~1.11",
"psr/log": "~1.0"
},
“minimum-stability”: “dev”
}
@stability flags, the specific solution
{
"require": {
"php": ">=5.3.3",
"symfony/icu": "~1.0",
"doctrine/common": “~2.2@dev",
"twig/twig": "~1.11",
"psr/log": "~1.0"
}
}
@stability flags, recursive stability
{
"require": {
"php": ">=5.3.3",
"symfony/icu": "~1.0",
"doctrine/orm": “~2.2",
"doctrine/dbal": “@dev",
"twig/twig": "~1.11",
"psr/log": "~1.0"
}
}
prefer-stable, the “magic” solution
{
"require": {
"php": ">=5.3.3",
"symfony/icu": "~1.0",
"doctrine/common": "~2.2",
"twig/twig": "~1.11",
"psr/log": "~1.0"
},
“prefer-stable”: true
}
Branch aliases
Branch aliases, the problem
Branch aliases, the bad practice

{
"require": {
“welovephp/foobar”: “dev-master”
}
}
Branch aliases, the solution
{
“name”: “welovephp/foobar”
"extra": {
"branch-alias": {
"dev-master": "2.5-dev"
}
}
}
Branch aliases & stability flags

{
"require": {
“welovephp/foobar”: “2.5.*@dev”
}
}
Branch aliases, inline aliases

{
"require": {
“welovephp/foobar”: “my-branch as 2.5-dev”

}
}
Semantic
Versioning
Semantic versioning

X.Y.Z
Semantic versioning

X.Y.Z
Semantic versioning

X.Y.Z
Semantic versioning

X.Y.Z
Semantic versioning

1.*
Semantic versioning

>=1.1,<2.0
Semantic versioning

~1.1
Private

Repositories
Private Repositories, the basics
{
“repositories”: [
{
“type”: “git”,
“url”: “git@github.com/welovephp/foobar.git”
}
]
}
Private Repositories, the basics
{
“repositories”: [
{ “type”: “git”, “url”: “git@github.com/welovephp/foobar.git” },
{ “type”: “git”, “url”: “git@github.com/welovephp/foobar-bundle.git” },
{ “type”: “git”, “url”: “git@github.com/welovephp/fizz.git” },
{ “type”: “git”, “url”: “git@github.com/welovephp/buzz.git” },
{ “type”: “git”, “url”: “git@github.com/welovephp/fizzbuzz-bundle.git” },
{ “type”: “git”, “url”: “git@github.com/welovephp/qwerty.git” },
{ “type”: “git”, “url”: “git@github.com/welovephp/doe.git” }
]
}
Private Repositories, the basics
Private Repositories, the basics
Private Repositories:

Satis
Private Repositories, Satis

$ composer create-project composer/satis
Private Repositories, Satis
// config.json
{
"name": "WelovePhp",
"homepage": "http://packages.welovephp.es",
"require-all": true,
“repositories”: [
{ “type”: “git”, “url”: “git@github.com/welovephp/foobar.git” },
{ “type”: “git”, “url”: “git@github.com/welovephp/foobar-bundle.git” },
{ “type”: “git”, “url”: “git@github.com/welovephp/fizz.git” },
{ “type”: “git”, “url”: “git@github.com/welovephp/buzz.git” },
{ “type”: “git”, “url”: “git@github.com/welovephp/fizzbuzz-bundle.git” },
{ “type”: “git”, “url”: “git@github.com/welovephp/qwerty.git” }
]
}
Private Repositories, Satis

$ php bin/satis build config.json web/
Private Repositories, Satis
Private Repositories, Satis
{
"repositories": [
{
"type": "composer",
"url": “http://packages.welovephp.es/“
}
]
}
Private Repositories, Satis
Security:

•

Basic HTTP Authentication


•

SSH


•

Private network

!

Updates

•

CRON job
Private Repositories:

Packagist
Private Repositories, Packagist

•

Packagist is an Open Source project


•

It is built as a Symfony application


•

You can have your own private Packagist


•

Supports Github Webhooks
Private Repositories, Packagist

Requirements:

•

MySQL


•

Redis


•

Solr


•

git / svn / hg
Private Repositories:

Bottlenecks
Private Repositories, the bottlenecks
Installers
Installers, the official ones
•

Wordpress


•

Drupal


•

CakePHP


•

CodeIgniter


•

Laravel


•

Tons more!

http://github.com/composer/installers
Installers, building your own installer
{
"name": "welovephp/blog-module",
"type": “welovephp-module",
"require": {
“welovephp/module-installer-plugin“: "*"
}
}
Installers, building your own installer
{
"name": “welovephp/module-installer-plugin",
"type": "composer-plugin",
"autoload": {
"psr-0": {"WeLovePhpComposer": "src/"}
},
"extra": {
"class": "WeLovePhpComposerModuleInstallerPlugin"
},
"require": { "composer-plugin-api": “1.0.0"
}

}
Installers, building your own installer
namespace WeLovePhpComposer;
class ModuleInstallerPlugin implements PluginInterface
{
public function activate(Composer $composer, IOInterface $io)
{
$installer = new ModuleInstaller($io, $composer);
$composer->getInstallationManager()->addInstaller($installer);
}
}
Installers, building your own installer
namespace phpDocumentorComposer;

!
class ModuleInstaller extends LibraryInstaller
{
public function getPackageBasePath(PackageInterface $package)
{
return 'welovephp/modules/'.$package->getPrettyName();
}

!
public function supports($packageType)
{
return ‘welovephp-module' === $packageType;
}
}
Embedded
Composer
By Beau Simensen
Embedded Composer, the problem
•

You have an application


•

Your application has dependencies


•

Your application can be extended via third-party
plugins


•

Those plugins depend on your app, but can have
other extra dependencies


•

Both, app & plugins dependencies, must be installed
once and be compatible between them
Embedded Composer, the solution

We need to be able to run Composer on runtime
Embedded Composer & Sculpin.io
Commands you
must know
diagnose

$ composer diagnose
Checks common errors to help debugging problems.
—verbose

$ composer command […] -v|vv|vvv
Increase output verbosity. Useful for debugging.
config —global

$ composer config —global […]
Read/Write Composer global settings.
global

$ composer global require phpunit/phpunit
Add COMPOSER_HOME/vendor/bin to PATH

!

Run Composer operations globally. Useful for CLI
tools.
status

$ composer status
Displays a list of dependencies that have been
modified locally.
show

$ composer show package/name
Displays detailed information about a package.
dump-autoload —optimize

$ composer dump-autoload —
optimize
Dumps a classmap for PSR-0 vendors.
Useful links
Useful links
Composer

•

http://getcomposer.org/doc/


•

https://github.com/composer/composer


•

https://packagist.org/


•

#composerphp at twitter


!
Composer Basics

•

http://www.slideshare.net/adanlobato/composer-gestor-de-dependencias-para-php


•

http://www.youtube.com/watch?v=U1dTiDlUUmU


•

http://adanlobato.github.io/composer-2013
Useful links
Minimum stability

•

http://getcomposer.org/doc/04-schema.md#minimum-stability


•

http://getcomposer.org/doc/04-schema.md#package-links


•

https://igor.io/2013/02/07/composer-stability-flags.html


!
Branch alias

•

http://getcomposer.org/doc/articles/aliases.md


•

https://igor.io/2013/01/07/composer-versioning.html


!
Semantic versioning

•

http://semver.org/
Useful links
Private Repositories

•

https://github.com/composer/satis


•

https://github.com/composer/packagist


•

https://help.github.com/articles/post-receive-hooks


!
Installers

•

http://getcomposer.org/doc/articles/custom-installers.md


•

https://github.com/composer/installers


!
Useful links

Embedded Composer

•

https://speakerdeck.com/simensen/embedded-composer-sflive-portland-2013


•

https://github.com/dflydev/dflydev-embedded-composer


•

https://github.com/sculpin


!
That’s all folks!
Questions?

More Related Content

What's hot (19)

PDF
Building real time applications with Symfony2
Antonio Peric-Mazar
 
PDF
Big Data! Great! Now What? #SymfonyCon 2014
Ricard Clau
 
PDF
Indexing BackPAN
brian d foy
 
ODP
CommandBox REPL, CLI, and Package Manager
bdw429s
 
PDF
CPAN Workshop, Chicago 2014
brian d foy
 
PDF
CommandBox at CFCamp 2014
Ortus Solutions, Corp
 
PDF
Live Coverage at The New York Times
Scott Taylor
 
PDF
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Pantheon
 
PPTX
PHP Dependency Management with Composer
Adam Englander
 
PDF
Introduction to ansible
Krish
 
PDF
Stress Free Deployment - Confoo 2011
Bachkoutou Toutou
 
PDF
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Michael Lihs
 
PPTX
Untangling fall2017 week1
Derek Jacoby
 
PDF
Rails on HBase
Tony Hillerson
 
PPTX
Untangling fall2017 week2
Derek Jacoby
 
PPTX
Continuous Delivery and Infrastructure as Code
Sascha Möllering
 
KEY
Productivity 101: Making a Easily Re-deployable Dev Environment with Subversion
ryanduff
 
PDF
REST In Action: The Live Coverage Platform at the New York Times
Scott Taylor
 
PDF
All the Laravel things: up and running to making $$
Joe Ferguson
 
Building real time applications with Symfony2
Antonio Peric-Mazar
 
Big Data! Great! Now What? #SymfonyCon 2014
Ricard Clau
 
Indexing BackPAN
brian d foy
 
CommandBox REPL, CLI, and Package Manager
bdw429s
 
CPAN Workshop, Chicago 2014
brian d foy
 
CommandBox at CFCamp 2014
Ortus Solutions, Corp
 
Live Coverage at The New York Times
Scott Taylor
 
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Pantheon
 
PHP Dependency Management with Composer
Adam Englander
 
Introduction to ansible
Krish
 
Stress Free Deployment - Confoo 2011
Bachkoutou Toutou
 
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Michael Lihs
 
Untangling fall2017 week1
Derek Jacoby
 
Rails on HBase
Tony Hillerson
 
Untangling fall2017 week2
Derek Jacoby
 
Continuous Delivery and Infrastructure as Code
Sascha Möllering
 
Productivity 101: Making a Easily Re-deployable Dev Environment with Subversion
ryanduff
 
REST In Action: The Live Coverage Platform at the New York Times
Scott Taylor
 
All the Laravel things: up and running to making $$
Joe Ferguson
 

Viewers also liked (13)

PDF
Composer: putting dependencies on the score
Rafael Dohms
 
PPSX
Homepage i TOS - #Moja Srbija
Marketing mreža
 
PPTX
Android tv market - March 2017 - analysis and commentary
paul young cpa, cga
 
PDF
Efficient development workflows with composer
nuppla
 
PDF
Ko konkuriše za nagradu EY Preduzetnik godine 2016?
Mila Dimitrijević
 
PDF
Design Patterns in Swift ch0 Introduction
Chihyang Li
 
ODP
Custom Android App Development – Web Animation India
Marion Welch
 
PPTX
Android coding guidlines
Krunal Doshi
 
ODP
PHP Web Programming
Muthuselvam RS
 
PPTX
How Much Does it Cost to Build a Mobile App for iPhone & Android?
Alex Sam
 
PDF
Introduction to PHP
Bradley Holt
 
PDF
How to deploy PHP projects with docker
Ruoshi Ling
 
PPTX
Smart Attendance Management System Using Android WIFI Technology
Sukanta Biswas
 
Composer: putting dependencies on the score
Rafael Dohms
 
Homepage i TOS - #Moja Srbija
Marketing mreža
 
Android tv market - March 2017 - analysis and commentary
paul young cpa, cga
 
Efficient development workflows with composer
nuppla
 
Ko konkuriše za nagradu EY Preduzetnik godine 2016?
Mila Dimitrijević
 
Design Patterns in Swift ch0 Introduction
Chihyang Li
 
Custom Android App Development – Web Animation India
Marion Welch
 
Android coding guidlines
Krunal Doshi
 
PHP Web Programming
Muthuselvam RS
 
How Much Does it Cost to Build a Mobile App for iPhone & Android?
Alex Sam
 
Introduction to PHP
Bradley Holt
 
How to deploy PHP projects with docker
Ruoshi Ling
 
Smart Attendance Management System Using Android WIFI Technology
Sukanta Biswas
 
Ad

Similar to Mastering composer (20)

PDF
Dependency management with Composer
Jason Grimes
 
PDF
Welcome to the Symfony2 World - FOSDEM 2013
Lukas Smith
 
PDF
Composing Project Dependencies
Derek Gallo
 
PDF
How composer saved PHP
Ryan Kilfedder
 
KEY
Composer
Tom Corrigan
 
PDF
Beginning with Composer - Dependency manager in php
Yogesh Salvi
 
PDF
Composer the Right Way - MM16NL
Rafael Dohms
 
PPTX
Nh php may 2014 - composer
David Weingart
 
PDF
Rebuilding our Foundation
Jessica Mauerhan
 
PDF
Shifting gears with Composer
Javier López
 
PDF
Composer - The missing package manager for PHP
Tareq Hasan
 
PDF
Lately in php - 2019 May 4
Eric Poe
 
PDF
12 Composer #burningkeyboards
Denis Ristic
 
PDF
Composer the right way [SweetlakePHP]
Rafael Dohms
 
PDF
Composer the right way
Rafael Dohms
 
PPTX
Last Month in PHP - March 2016
Eric Poe
 
PDF
Silex: From nothing to an API
chrisdkemper
 
PDF
Composer The Right Way - 010PHP
Rafael Dohms
 
Dependency management with Composer
Jason Grimes
 
Welcome to the Symfony2 World - FOSDEM 2013
Lukas Smith
 
Composing Project Dependencies
Derek Gallo
 
How composer saved PHP
Ryan Kilfedder
 
Composer
Tom Corrigan
 
Beginning with Composer - Dependency manager in php
Yogesh Salvi
 
Composer the Right Way - MM16NL
Rafael Dohms
 
Nh php may 2014 - composer
David Weingart
 
Rebuilding our Foundation
Jessica Mauerhan
 
Shifting gears with Composer
Javier López
 
Composer - The missing package manager for PHP
Tareq Hasan
 
Lately in php - 2019 May 4
Eric Poe
 
12 Composer #burningkeyboards
Denis Ristic
 
Composer the right way [SweetlakePHP]
Rafael Dohms
 
Composer the right way
Rafael Dohms
 
Last Month in PHP - March 2016
Eric Poe
 
Silex: From nothing to an API
chrisdkemper
 
Composer The Right Way - 010PHP
Rafael Dohms
 
Ad

Recently uploaded (20)

PDF
The Past, Present & Future of Kenya's Digital Transformation
Moses Kemibaro
 
PDF
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
PPTX
The Yotta x CloudStack Advantage: Scalable, India-First Cloud
ShapeBlue
 
PDF
CIFDAQ'S Token Spotlight for 16th July 2025 - ALGORAND
CIFDAQ
 
PPTX
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 
PDF
HR agent at Mediq: Lessons learned on Agent Builder & Maestro by Tacstone Tec...
UiPathCommunity
 
PDF
Lecture A - AI Workflows for Banking.pdf
Dr. LAM Yat-fai (林日辉)
 
PDF
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
PDF
Rethinking Security Operations - Modern SOC.pdf
Haris Chughtai
 
PPTX
AI Code Generation Risks (Ramkumar Dilli, CIO, Myridius)
Priyanka Aash
 
PPTX
Top Managed Service Providers in Los Angeles
Captain IT
 
PDF
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
PDF
Women in Automation Presents: Reinventing Yourself — Bold Career Pivots That ...
DianaGray10
 
PPTX
Simplifying End-to-End Apache CloudStack Deployment with a Web-Based Automati...
ShapeBlue
 
PDF
visibel.ai Company Profile – Real-Time AI Solution for CCTV
visibelaiproject
 
PDF
Alpha Altcoin Setup : TIA - 19th July 2025
CIFDAQ
 
PDF
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
PDF
Trading Volume Explained by CIFDAQ- Secret Of Market Trends
CIFDAQ
 
PDF
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
PDF
Novus Safe Lite- What is Novus Safe Lite.pdf
Novus Hi-Tech
 
The Past, Present & Future of Kenya's Digital Transformation
Moses Kemibaro
 
Human-centred design in online workplace learning and relationship to engagem...
Tracy Tang
 
The Yotta x CloudStack Advantage: Scalable, India-First Cloud
ShapeBlue
 
CIFDAQ'S Token Spotlight for 16th July 2025 - ALGORAND
CIFDAQ
 
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 
HR agent at Mediq: Lessons learned on Agent Builder & Maestro by Tacstone Tec...
UiPathCommunity
 
Lecture A - AI Workflows for Banking.pdf
Dr. LAM Yat-fai (林日辉)
 
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
Rethinking Security Operations - Modern SOC.pdf
Haris Chughtai
 
AI Code Generation Risks (Ramkumar Dilli, CIO, Myridius)
Priyanka Aash
 
Top Managed Service Providers in Los Angeles
Captain IT
 
TrustArc Webinar - Data Privacy Trends 2025: Mid-Year Insights & Program Stra...
TrustArc
 
Women in Automation Presents: Reinventing Yourself — Bold Career Pivots That ...
DianaGray10
 
Simplifying End-to-End Apache CloudStack Deployment with a Web-Based Automati...
ShapeBlue
 
visibel.ai Company Profile – Real-Time AI Solution for CCTV
visibelaiproject
 
Alpha Altcoin Setup : TIA - 19th July 2025
CIFDAQ
 
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
Trading Volume Explained by CIFDAQ- Secret Of Market Trends
CIFDAQ
 
Meetup Kickoff & Welcome - Rohit Yadav, CSIUG Chairman
ShapeBlue
 
Novus Safe Lite- What is Novus Safe Lite.pdf
Novus Hi-Tech
 

Mastering composer