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

Managing private composer packages

reenl
August 14, 2014

Managing private composer packages

Everybody in the open source community knows about Composer, THE dependency manager for php. The reason for this success is probably the ease of use for both installing and creating packages. This talk is about using Composer in a corporate environment.

This talk is about how to use composer and how to create your own repository.

reenl

August 14, 2014
Tweet

Other Decks in Programming

Transcript

  1. Version selection  Fixed: 1.0.2  Range: >=1.0  And:

    >=1.0,<1.1  Wildcard: 1.0.*  Tilde: ~1.2 >=1.2,<2.0
  2. Why tilde rocks  awesome/package  monolog/monolog: ~1.2  reen/package

     awesome/package : ~1.0  monolog/monolog: ~1.3
  3. (My) Composer Flow  Composer install --prefer-source  Development 

    Composer update --prefer-source  After composer.json modification  Bugfixes for dependencies  Commit composer.lock!  Composer install --no-dev --optimize-autoloader  Deployment
  4.  Composer install and update  Require autoloader  Use

    tilde ~ for dependencies  Semantic versioning Composer basics
  5. Satis.json { "name": "Alphacomm", "homepage": "https://packages.alphacomm.nl", "output-dir": "web", "repositories": [

    { "type": "vcs", "url": "https://user:[email protected]/alphacomm/acgr-sms-api.git" } ], "require-all": true }
  6. Satis: Host dependencies { "repositories": [ { "type": "composer", "url":

    "https://packagist.org" }, { "type": "vcs", "url": "https://user:[email protected]/alphacomm/acgr-sms-api.git" } ], "require-all": false, "require-dependencies": true, "require": { "alphacomm/sms-api": "*" } }
  7. Authentication  Add basic http auth to webserver  Create

    deploy user  Configure composer (globally?) <Directory /path/to/web> AuthType Basic AuthName "Authentication Required" AuthUserFile "/path/to/.htpasswd" Require valid-user </Directory> ❯ composer config http-basic.<host> <deploy-user> <deploy-password>
  8. Satis: Summary  Satis installation  Require packages in satis.json

     Enable in project: ❯ composer config repositories.alphacomm composer https://packages.alphacomm.nl
  9. Disabling packagist  Remove packagist.org  Issue: can’t add new

    dependencies without waiting for satis build { "repositories": [ { "packagist": false }, { "type": "composer", "url": "https://packages.alphacomm.nl" } ] }