Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Composer: Stability and Semantic Versioning Dem...

Beau Simensen
November 16, 2013

Composer: Stability and Semantic Versioning Demystified (Madison PHP)

Understanding stability and semantic versioning makes a huge impact on daily life with Composer. Learn how to decode Composer's solver errors, get a better understanding of semantic versioning, how dependencies interact with each other when it comes to stability, and how to use Composer features like branch aliases to make things run more smoothly.

Beau Simensen

November 16, 2013
Tweet

More Decks by Beau Simensen

Other Decks in Programming

Transcript

  1. { “name”: “acme/my-project”, “description”: “Acme’s My Project”, “license”: “MIT”, “require”:

    { “silex/silex”: “1.1.*” }, “autoload”: { “psr-0”: { “Acme\\MyProject\\”: “src” } } }
  2. { “name”: “acme/my-project”, “description”: “Acme’s My Project”, “license”: “MIT”, “require”:

    { “silex/silex”: “1.1.*” }, “autoload”: { “psr-0”: { “Acme\\MyProject\\”: “src” } } }
  3. { “name”: “acme/my-project”, “description”: “Acme’s My Project”, “license”: “MIT”, “require”:

    { “silex/silex”: “1.1.*” }, “autoload”: { “psr-0”: { “Acme\\MyProject\\”: “src” } } }
  4. { “name”: “acme/my-project”, “description”: “Acme’s My Project”, “license”: “MIT”, “require”:

    { “silex/silex”: “1.1.*” }, “autoload”: { “psr-0”: { “Acme\\MyProject\\”: “src” } } }
  5. $ composer install Loading composer repositories with package information Installing

    dependencies (including require-dev) - Installing psr/log (1.0.0) - Installing symfony/routing (v2.3.7) - Installing symfony/debug (v2.3.7) - Installing symfony/http-foundation (v2.3.7) - Installing symfony/event-dispatcher (v2.3.7) - Installing symfony/http-kernel (v2.3.7) - Installing pimple/pimple (v1.1.0) - Installing silex/silex (v1.1.2) Writing lock file Generating autoload files $
  6. Other Version Schemes Can Be Used But don’t expect Composer

    to read your mind and do anything smart with them.
  7. If the dependency specifications are too tight, you are in

    danger of version lock (the inability to upgrade a package without having to release new versions of every dependent package). — Semantic Versioning http://semver.org/
  8. If dependencies are specified too loosely, you will inevitably be

    bitten by version promiscuity (assuming compatibility with more future versions than is reasonable). — Semantic Versioning http://semver.org/
  9. { “name”: “silex/silex”, “require”: { “pimple/pimple”: “1.*” } } {

    “name”: “dflydev/doctrine-orm-service-provider”, “require”: { “pimple/pimple”: “1.*”, “doctrine/orm”: “~2.3” } }
  10. { “require”: { “dflydev/doctrine-orm-service-provider”: “1.0.*”, “silex/silex”: “1.1.*”, “pimple/pimple”: “1.0.*”, “doctrine/orm”:

    “2.4.*” } } { “name”: “silex/silex”, “require”: { “pimple/pimple”: “1.*” } } { “name”: “dflydev/doctrine-orm-service-provider”, “require”: { “pimple/pimple”: “1.*”, “doctrine/orm”: “~2.3” } }
  11. $ composer install Loading composer repositories with package information Installing

    dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages. Problem 1 - silex/silex v1.1.0 requires pimple/pimple 1.* -> satisfiable by pimple/pimple[1.0.0, 1.1.x-dev, v1.0.1, v1.0.2, v1.1.0]. - silex/silex v1.1.1 requires pimple/pimple 1.* -> satisfiable by pimple/pimple[1.0.0, 1.1.x-dev, v1.0.1, v1.0.2, v1.1.0]. - silex/silex v1.1.2 requires pimple/pimple ~1.0 -> satisfiable by pimple/pimple[1.0.0, 1.1.x-dev, v1.0.1, v1.0.2, v1.1.0]. - Can only install one of: pimple/pimple[2.0.x-dev, 1.0.0]. - Can only install one of: pimple/pimple[2.0.x-dev, 1.1.x-dev]. - Can only install one of: pimple/pimple[v1.0.1, 2.0.x-dev]. - Can only install one of: pimple/pimple[v1.0.2, 2.0.x-dev]. - Can only install one of: pimple/pimple[v1.1.0, 2.0.x-dev]. - Installation request for pimple/pimple 2.0.*@dev -> satisfiable by pimple/pimple[2.0.x-dev]. - Installation request for silex/silex 1.1.* -> satisfiable by silex/silex[v1.1.0, v1.1.1, v1.1.2]. Potential causes: - A typo in the package name - The package is not available in a stable-enough version according to your minimum-stability setting.
  12. Tags If it cannot be parsed for semantic versioning, it

    is treated as if it were an “exact” version.
  13. Branches Composer can alias a named branch to a specific

    development version. Branch named master is treated as 2.0.*@dev
  14. When starting a new library that is to be distributed

    via Packagist / Composer, be SURE to set up your dev-master branch alias. — Don Gilbert https://twitter.com/dilbert4life/status/380137097614458881
  15. $ composer install Loading composer repositories with package information Installing

    dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages. Problem 1 - The requested package pimple/pimple 2.0.* could not be found. Potential causes: - A typo in the package name - The package is not available in a stable-enough version according to your minimum-stability setting Stability
  16. $ composer install Loading composer repositories with package information Installing

    dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages. Problem 1 - The requested package pimple/pimple 2.0.* could not be found. Potential causes: - A typo in the package name - The package is not available in a stable-enough version according to your minimum-stability setting Stability
  17. Stability Even if your package requires something @dev, users of

    your package won’t get it unless they explicitly ask for it.
  18. R { “name”: “silex/silex”, “require”: { “pimple/pimple”: “1.*@dev” } }

    { “name”: “dflydev/doctrine-orm-service-provider”, “require”: { “pimple/pimple”: “1.*@beta”, “silex/silex”: “1.1.*”, “doctrine/orm”: “~2.3” } }
  19. { “require”: { “dflydev/doctrine-orm-service-provider”: “1.0.*”, “pimple/pimple”: “1.0.*” } } {

    “name”: “silex/silex”, “require”: { “pimple/pimple”: “1.*@dev” } } { “name”: “dflydev/doctrine-orm-service-provider”, “require”: { “pimple/pimple”: “1.*@beta”, “silex/silex”: “1.1.*”, “doctrine/orm”: “~2.3” } } R