SlideShare a Scribd company logo
1 of 124
Download to read offline
Rafael Dohms / @rdohms




C!"p#$r
   Putting your dependencies on the score
Rafael Dohms




                           photo credit: Eli White
        @rdohms


 Evangelist, Speaker and
      Contributor.

Developer at WEBclusive.

Enabler at AmsterdamPHP.
%$ E&$v'(!r P)(*+
     a general introduction to Composer




     Ev$r,-', *!"p#)./
      the basic stuff you need to know




  Up/r'-)./ (! ' M'$0(r!
advanced features for more complex scenarios




       1.-)./ ,!2r (2.$
      discovering and sharing libraries
%$ E&$v'(!r P)(*+
per project          system wide
central repository   spread out channels
open acceptance        strict standards
Pr!b&$":
I need my team and my deployments to use consistent
      versions of the dependencies of my project
Pr!b&$":
I need my team and my deployments to use consistent
      versions of the dependencies of my project


S!&2()!.:
Pr!b&$":
I need my team and my deployments to use consistent
      versions of the dependencies of my project


S!&2()!.:
                       PEAR
Pr!b&$":
I need my team and my deployments to use consistent
      versions of the dependencies of my project


S!&2()!.:
                      PEAR
                   SVN Externals
Pr!b&$":
I need my team and my deployments to use consistent
      versions of the dependencies of my project


S!&2()!.:
                       PEAR
                   SVN Externals
                  Git Submodules
Pr!b&$":
I need my team and my deployments to use consistent
      versions of the dependencies of my project


S!&2()!.:
                      PEAR
                  SVN Externals
                 Git Submodules
             vendor management script
Pr!b&$":
I need my team and my deployments to use consistent
      versions of the dependencies of my project


S!&2()!.:
                      PEAR
                  SVN Externals
                 Git Submodules
             vendor management script


                  C!"p#$r!
A per-project dependency
  manager that allows you to
  declare a consistent list of
dependencies and versions for
 your application, as well as a
consistent way of sharing your
  libraries and making them
      discoverable using
         packagist.org
Ev$r,-', C!"p#)./
I.0('&&)./ C!"p#$r

Local (embed)
$ curl -s http://getcomposer.org/installer | php


Global
$ curl -s http://getcomposer.org/installer | php -- --install-dir=bin
I.0('&&)./ C!"p#$r

Local (embed)
$ curl -s http://getcomposer.org/installer | php


Global
$ curl -s http://getcomposer.org/installer | php -- --install-dir=bin




       3p:    $ ln -s /usr/bin/composer.phar /usr/bin/composer
I.0('&&)./ C!"p#$r
I.0('&&)./ C!"p#$r



  $ composer.phar --version
  Composer version 6573fd3
I.0('&&)./ C!"p#$r


     php

  $ composer.phar --version
  Composer version 6573fd3
K$$p )( 2p-'($-!
K$$p )( 2p-'($-!



$ composer.phar self-update

Updating to version 65e95ed.
    Downloading: 100%
C!"p#$r 101
C!"p#$r 101

$ cd ~/dev/myproject
C!"p#$r 101

$ cd ~/dev/myproject
$ vim composer.json



    {
        "require": {
            "silex/silex": "1.0.*"
        },

        "minimum-stability": "dev"
    }
C!"p#$r 101

$ cd ~/dev/myproject
$ vim composer.json       note: project root




    {
        "require": {
            "silex/silex": "1.0.*"
        },

        "minimum-stability": "dev"
    }
C!"p#$r 101

$ cd ~/dev/myproject
$ vim composer.json       note: project root



                                         “require”: required packages and versions
    {
        "require": {
                                                adv. ex.: >=1.0.0,<1.2-dev
            "silex/silex": "1.0.*"
        },

        "minimum-stability": "dev"
    }
C!"p#$r 101

$ cd ~/dev/myproject
$ vim composer.json       note: project root



                                         “require”: required packages and versions
    {
        "require": {
                                                 adv. ex.: >=1.0.0,<1.2-dev
            "silex/silex": "1.0.*"
        },

        "minimum-stability": "dev"       “minimum-stability”: if you only want stable
    }                                                    packages

                                                       default: stable
C!"p#$r 101

$ cd ~/dev/myproject
$ vim composer.json        note: project root



                                          “require”: required packages and versions
    {
        "require": {
                                                  adv. ex.: >=1.0.0,<1.2-dev
            "silex/silex": "1.0.*"
        },

        "minimum-stability": "dev"        “minimum-stability”: if you only want stable
    }                                                     packages

                                                        default: stable


$ composer.phar install
Installing dependencies
  - Installing pimple/pimple (dev-master)
    Cloning d2cfa2f02f50abef65c238747c753a5f6786f6be

  - Installing symfony/routing (dev-master)
    Cloning 6bca82c3ea0d42d750de4f49b22020dfd047dc0f

  - Installing symfony/http-foundation (dev-master)
    Cloning 498c2da9c3fecefc7e3b0add73621f3feb337ddd

  - Installing symfony/event-dispatcher (dev-master)
    Cloning b99b49760016467099f010aff7a5098861d49e09

  - Installing symfony/http-kernel (dev-master)
    Cloning 7f671472f009231f9c1f5ec9b81fc6fbfcd9a955

  - Installing silex/silex (dev-master)
    Cloning 18e248a277adb061602d2bcabe96011db1c76ec0

symfony/routing suggests installing symfony/config (dev-master)
symfony/routing suggests installing symfony/yaml (dev-master)
symfony/routing suggests installing doctrine/common (>=2.2,<2.4-dev)
symfony/event-dispatcher suggests installing symfony/dependency-injection (dev-master)
symfony/http-kernel suggests installing symfony/browser-kit (dev-master)
symfony/http-kernel suggests installing symfony/class-loader (dev-master)
symfony/http-kernel suggests installing symfony/config (dev-master)
symfony/http-kernel suggests installing symfony/console (dev-master)
symfony/http-kernel suggests installing symfony/dependency-injection (dev-master)
symfony/http-kernel suggests installing symfony/finder (dev-master)
silex/silex suggests installing symfony/browser-kit (2.1.*)
silex/silex suggests installing symfony/css-selector (2.1.*)
silex/silex suggests installing symfony/dom-crawler (2.1.*)
Writing lock file
Generating autoload files
Installing dependencies
  - Installing pimple/pimple (dev-master)
    Cloning d2cfa2f02f50abef65c238747c753a5f6786f6be

  - Installing symfony/routing (dev-master)
    Cloning 6bca82c3ea0d42d750de4f49b22020dfd047dc0f

  - Installing symfony/http-foundation (dev-master)
                                                          your dependency’s dependencies
    Cloning 498c2da9c3fecefc7e3b0add73621f3feb337ddd

  - Installing symfony/event-dispatcher (dev-master)
    Cloning b99b49760016467099f010aff7a5098861d49e09

  - Installing symfony/http-kernel (dev-master)
    Cloning 7f671472f009231f9c1f5ec9b81fc6fbfcd9a955

  - Installing silex/silex (dev-master)
    Cloning 18e248a277adb061602d2bcabe96011db1c76ec0

symfony/routing suggests installing symfony/config (dev-master)
symfony/routing suggests installing symfony/yaml (dev-master)
symfony/routing suggests installing doctrine/common (>=2.2,<2.4-dev)
symfony/event-dispatcher suggests installing symfony/dependency-injection (dev-master)
symfony/http-kernel suggests installing symfony/browser-kit (dev-master)
symfony/http-kernel suggests installing symfony/class-loader (dev-master)
symfony/http-kernel suggests installing symfony/config (dev-master)
symfony/http-kernel suggests installing symfony/console (dev-master)
symfony/http-kernel suggests installing symfony/dependency-injection (dev-master)
symfony/http-kernel suggests installing symfony/finder (dev-master)
silex/silex suggests installing symfony/browser-kit (2.1.*)
silex/silex suggests installing symfony/css-selector (2.1.*)
silex/silex suggests installing symfony/dom-crawler (2.1.*)
Writing lock file
Generating autoload files
Installing dependencies
  - Installing pimple/pimple (dev-master)
    Cloning d2cfa2f02f50abef65c238747c753a5f6786f6be

  - Installing symfony/routing (dev-master)
    Cloning 6bca82c3ea0d42d750de4f49b22020dfd047dc0f

  - Installing symfony/http-foundation (dev-master)
                                                          your dependency’s dependencies
    Cloning 498c2da9c3fecefc7e3b0add73621f3feb337ddd

  - Installing symfony/event-dispatcher (dev-master)
    Cloning b99b49760016467099f010aff7a5098861d49e09

  - Installing symfony/http-kernel (dev-master)
    Cloning 7f671472f009231f9c1f5ec9b81fc6fbfcd9a955

  - Installing silex/silex (dev-master)
    Cloning 18e248a277adb061602d2bcabe96011db1c76ec0              your dependency

symfony/routing suggests installing symfony/config (dev-master)
symfony/routing suggests installing symfony/yaml (dev-master)
symfony/routing suggests installing doctrine/common (>=2.2,<2.4-dev)
symfony/event-dispatcher suggests installing symfony/dependency-injection (dev-master)
symfony/http-kernel suggests installing symfony/browser-kit (dev-master)
symfony/http-kernel suggests installing symfony/class-loader (dev-master)
symfony/http-kernel suggests installing symfony/config (dev-master)
symfony/http-kernel suggests installing symfony/console (dev-master)
symfony/http-kernel suggests installing symfony/dependency-injection (dev-master)
symfony/http-kernel suggests installing symfony/finder (dev-master)
silex/silex suggests installing symfony/browser-kit (2.1.*)
silex/silex suggests installing symfony/css-selector (2.1.*)
silex/silex suggests installing symfony/dom-crawler (2.1.*)
Writing lock file
Generating autoload files
Installing dependencies
  - Installing pimple/pimple (dev-master)
    Cloning d2cfa2f02f50abef65c238747c753a5f6786f6be

  - Installing symfony/routing (dev-master)
    Cloning 6bca82c3ea0d42d750de4f49b22020dfd047dc0f

  - Installing symfony/http-foundation (dev-master)
                                                          your dependency’s dependencies
    Cloning 498c2da9c3fecefc7e3b0add73621f3feb337ddd

  - Installing symfony/event-dispatcher (dev-master)
    Cloning b99b49760016467099f010aff7a5098861d49e09

  - Installing symfony/http-kernel (dev-master)
    Cloning 7f671472f009231f9c1f5ec9b81fc6fbfcd9a955

  - Installing silex/silex (dev-master)
    Cloning 18e248a277adb061602d2bcabe96011db1c76ec0              your dependency

symfony/routing suggests installing symfony/config (dev-master)
symfony/routing suggests installing symfony/yaml (dev-master)
symfony/routing suggests installing doctrine/common (>=2.2,<2.4-dev)
symfony/event-dispatcher suggests installing symfony/dependency-injection (dev-master)
symfony/http-kernel suggests installing symfony/browser-kit (dev-master)
symfony/http-kernel suggests installing symfony/class-loader (dev-master)
symfony/http-kernel suggests installing symfony/config (dev-master)
symfony/http-kernel suggests installing symfony/console (dev-master)
symfony/http-kernel suggests installing symfony/dependency-injection (dev-master)
symfony/http-kernel suggests installing symfony/finder (dev-master)
silex/silex suggests installing symfony/browser-kit (2.1.*)
silex/silex suggests installing symfony/css-selector (2.1.*)
silex/silex suggests installing symfony/dom-crawler (2.1.*)     suggestions of other packages,
Writing lock file
Generating autoload files
                                                                      for further features
P)*42p (+$ ($"p!!
Let Composer bootstrap you development
B!!(0(r'pp)./ Pr!5$*(0

$ composer.phar create-project fabpot/silex-skeleton ~/dev/myproject
B!!(0(r'pp)./ Pr!5$*(0

$ composer.phar create-project fabpot/silex-skeleton ~/dev/myproject




Installing fabpot/silex-skeleton (dev-master cc19d406cf3cac253715db92d400992d4f3e1b52)
  - Installing fabpot/silex-skeleton (dev-master)
    Cloning master

Created project in one-liner/
Installing dependencies
  - Installing pimple/pimple (dev-master)
    Cloning d2cfa2f02f50abef65c238747c753a5f6786f6be

  [...]

symfony/routing suggests installing symfony/yaml (dev-master)
[...]

Writing lock file
Generating autoload files
B!!(0(r'pp)./ Pr!5$*(0

$ composer.phar create-project fabpot/silex-skeleton ~/dev/myproject




Installing fabpot/silex-skeleton (dev-master cc19d406cf3cac253715db92d400992d4f3e1b52)
  - Installing fabpot/silex-skeleton (dev-master)
    Cloning master

Created project in one-liner/                                     myproje
                                                                          ct/
Installing dependencies                                             compose
  - Installing pimple/pimple (dev-master)                                   r.json
                                                                    compose
    Cloning d2cfa2f02f50abef65c238747c753a5f6786f6be                        r.lock
                                                                    config/
  [...]                                                            console
                                                                           /
                                                                   src/
symfony/routing suggests installing symfony/yaml (dev-master)
                                                                   templat
[...]                                                                      es/
                                                                  vendor/
Writing lock file                                                 web/
Generating autoload files
I w'.( (! *!.(r)b2($ ' pr!5$*(
  Composer can set that up for you.
B!!(0(r'pp)./ C!.(r)b2()!.0

$ composer.phar create-project dms/dms --dev ~/dev/oss/dms
B!!(0(r'pp)./ C!.(r)b2()!.0
                                        gimme dev packages


$ composer.phar create-project dms/dms --dev ~/dev/oss/dms
B!!(0(r'pp)./ C!.(r)b2()!.0
                                        gimme dev packages


$ composer.phar create-project dms/dms --dev ~/dev/oss/dms




          "require-dev": {
              "symfony/symfony": ">=2.1-dev",
              "doctrine/orm":    "dev-master"
          },
B!!(0(r'pp)./ C!.(r)b2()!.0
                                                  gimme dev packages


$ composer.phar create-project dms/dms --dev ~/dev/oss/dms




          "require-dev": {
              "symfony/symfony": ">=2.1-dev",
              "doctrine/orm":    "dev-master"
          },
            “require-dev”: only needed if you are going
                           to contribute
H!w -! I 6.-/&!'- (+$ 6&$0?
  PSR-0 and the modern autoloader
Composer generates an
autoload file for all your
     dependencies
Composer generates an
autoload file for all your
     dependencies


   vendor/autoload.php
"autoload": {
    "psr-0": { "MyNamespace": "<root>" },



     "classmap": ["src/", "lib/", "Something.php"],



     "files": ["src/MyLibrary/functions.php"]

},
“autoload”: describes the autoloading needed for your library


"autoload": {
    "psr-0": { "MyNamespace": "<root>" },



     "classmap": ["src/", "lib/", "Something.php"],



     "files": ["src/MyLibrary/functions.php"]

},
“autoload”: describes the autoloading needed for your library


"autoload": {
    "psr-0": { "MyNamespace": "<root>" },                   “psr-0”: PSR-0 Compatible libraries



     "classmap": ["src/", "lib/", "Something.php"],



     "files": ["src/MyLibrary/functions.php"]

},
“autoload”: describes the autoloading needed for your library


"autoload": {
    "psr-0": { "MyNamespace": "<root>" },                   “psr-0”: PSR-0 Compatible libraries



                                             “classmap”: Old PEAR packages and other
     "classmap": ["src/", "lib/", "Something.php"],
                                                             libraries


     "files": ["src/MyLibrary/functions.php"]

},
“autoload”: describes the autoloading needed for your library


"autoload": {
    "psr-0": { "MyNamespace": "<root>" },                   “psr-0”: PSR-0 Compatible libraries



                                             “classmap”: Old PEAR packages and other
     "classmap": ["src/", "lib/", "Something.php"],
                                                             libraries


     "files": ["src/MyLibrary/functions.php"]
                                                         “files”: for php functions or initializations
},
I.0('&&)./, 2p-'()./ '.- "!v)./ !.
  how does Composer guarantee consistency
composer.json
“composer.json”: metadata and list of your
              dependencies.




composer.json
“composer.json”: metadata and list of your
              dependencies.




composer.json



composer.lock
“composer.json”: metadata and list of your
              dependencies.




composer.json



composer.lock



 “composer.lock”: existing dependencies and
          current commit hashes.
composer.json



composer.lock
update



         composer.json



         composer.lock
update                   install



         composer.json



         composer.lock
update                           install


         reads
                 composer.json



                 composer.lock
update                             install


         reads
                   composer.json



                   composer.lock




     gets latest
update                                    install


         reads
                          composer.json


                 writes
                          composer.lock




     gets latest
update                                       install


         reads                            reads

                          composer.json


                 writes
                          composer.lock




     gets latest
update                                         install


         reads                             reads

                          composer.json

                                          compares
                 writes
                          composer.lock




     gets latest
update                                              install


         reads                                  reads

                          composer.json

                                              compares
                 writes
                          composer.lock




     gets latest                          gets locked version
D$v$&!p)./ '. App ). ' ($'"?

 Commit you composer.lock file
  into the repository, and use
        composer install.
D$v$&!p)./ '. App ). ' ($'"?

 Commit you composer.lock file
  into the repository, and use
        composer install.

                  will ensure everyone is on
                       the same “page”
I’" -$v$&!p)./ ' &)br'r,, +$&p!
here are some fields you should care about
{
    "name": "vendor-namespace/package-name",
    "type": "symfony-bundle",
    "description": "A sample package for examples",
    "keywords": ["php", "package"],
    "homepage": "http://doh.ms",
    "license": "MIT",
    "support": {
        "email": "support@mylib.com",
        "issues": "http://issues.lib.com"
    }

    "target-dir": "/folder/to/install",
}
“name”: this should be unique, pick a good one!
{
    "name": "vendor-namespace/package-name",
    "type": "symfony-bundle",
    "description": "A sample package for examples",
    "keywords": ["php", "package"],
    "homepage": "http://doh.ms",
    "license": "MIT",
    "support": {
        "email": "support@mylib.com",
        "issues": "http://issues.lib.com"
    }

    "target-dir": "/folder/to/install",
}
“name”: this should be unique, pick a good one!
{
    "name": "vendor-namespace/package-name",
                                 “type”: will be used for more advanced
    "type": "symfony-bundle",                “custom”installs
    "description": "A sample package for examples",
    "keywords": ["php", "package"],
    "homepage": "http://doh.ms",
    "license": "MIT",
    "support": {
        "email": "support@mylib.com",
        "issues": "http://issues.lib.com"
    }

    "target-dir": "/folder/to/install",
}
“name”: this should be unique, pick a good one!
{
    "name": "vendor-namespace/package-name",
                                 “type”: will be used for more advanced
    "type": "symfony-bundle",                “custom”installs
    "description": "A sample package for examples",
    "keywords": ["php", "package"],
    "homepage": "http://doh.ms",
    "license": "MIT",                      “license”: very important!
    "support": {
        "email": "support@mylib.com",
        "issues": "http://issues.lib.com"
    }

    "target-dir": "/folder/to/install",
}
“name”: this should be unique, pick a good one!
{
    "name": "vendor-namespace/package-name",
                                 “type”: will be used for more advanced
    "type": "symfony-bundle",                “custom”installs
    "description": "A sample package for examples",
    "keywords": ["php", "package"],
    "homepage": "http://doh.ms",
    "license": "MIT",                      “license”: very important!
    "support": {
        "email": "support@mylib.com",
                                     “support”: point people the right way.
        "issues": "http://issues.lib.com"
    }

    "target-dir": "/folder/to/install",
}
“name”: this should be unique, pick a good one!
{
    "name": "vendor-namespace/package-name",
                                 “type”: will be used for more advanced
    "type": "symfony-bundle",                “custom”installs
    "description": "A sample package for examples",
    "keywords": ["php", "package"],
    "homepage": "http://doh.ms",
    "license": "MIT",                      “license”: very important!
    "support": {
        "email": "support@mylib.com",
                                     “support”: point people the right way.
        "issues": "http://issues.lib.com"
    }

    "target-dir": "/folder/to/install",
}

           “target-dir”: great for installing sub-dir splits repositories

                ex: Symfony Bundles: /Acme/Bundle/MyBundle
M, *!-$ )0 PHP 5.4 !.&,!
 managing system dependencies
{
    "require": {
        "php": ">=5.3.3",
        "ext-ldap": "*"
    }
}
{                     “php”: PHP version.
    "require": {
        "php": ">=5.3.3",
        "ext-ldap": "*"
    }
}
{                         “php”: PHP version.
    "require": {
        "php": ">=5.3.3",
        "ext-ldap": "*"
    }
}                “ext-*”: Presence of selected extension
Up/r'-)./ (! ' M'$0(r!
B2( I .$$- ' 0p$*)6* v$r0)!.
  version modifiers to the rescue!
"acme/foo": "1.0.x-dev#3ebbe75"
“#<ref>”: Get this specific commit


"acme/foo": "1.0.x-dev#3ebbe75"
“#<ref>”: Get this specific commit


"acme/foo": "1.0.x-dev#3ebbe75"




      "acme/foo": "@dev"
   "acme/foo": "1.0.*@beta"
“#<ref>”: Get this specific commit


"acme/foo": "1.0.x-dev#3ebbe75"




      "acme/foo": "@dev"
   "acme/foo": "1.0.*@beta"


    “@<state>”: Get a version outside
          your default stability
I .$$- (! 7$*2($ ' f$w 0*r)p(0
 how to automate tasks with Composer
    "scripts": {
        "post-install-cmd": [
            "SensioBundleDistributionBundleComposerScriptHandler::buildBootstrap",
            "SensioBundleDistributionBundleComposerScriptHandler::clearCache",
            "SensioBundleDistributionBundleComposerScriptHandler::installAssets",
            "SensioBundleDistributionBundleComposerScriptHandler::installRequirementsFile"
        ],
        "post-update-cmd": [
            "SensioBundleDistributionBundleComposerScriptHandler::buildBootstrap",
            "SensioBundleDistributionBundleComposerScriptHandler::clearCache",
            "SensioBundleDistributionBundleComposerScriptHandler::installAssets",
            "SensioBundleDistributionBundleComposerScriptHandler::installRequirementsFile"
        ]
    },
“scripts”: allows you to run scripts at given moments

    "scripts": {
        "post-install-cmd": [
            "SensioBundleDistributionBundleComposerScriptHandler::buildBootstrap",
            "SensioBundleDistributionBundleComposerScriptHandler::clearCache",
            "SensioBundleDistributionBundleComposerScriptHandler::installAssets",
            "SensioBundleDistributionBundleComposerScriptHandler::installRequirementsFile"
        ],
        "post-update-cmd": [
            "SensioBundleDistributionBundleComposerScriptHandler::buildBootstrap",
            "SensioBundleDistributionBundleComposerScriptHandler::clearCache",
            "SensioBundleDistributionBundleComposerScriptHandler::installAssets",
            "SensioBundleDistributionBundleComposerScriptHandler::installRequirementsFile"
        ]
    },
C20(!" R$p#)(!r)$0 !r .!
 C!"p#$r, w+'( .!w?
Injecting Composer into wild packages
“hero/superpackage”: “dev-master”
“hero/superpackage”: “dev-master”
“hero/superpackage”: “dev-master”
“hero/superpackage”: “dev-master”
“hero/superpackage”: “dev-master”




    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/rdohms/hero-superpackage"
        }       
    ]
“hero/superpackage”: “dev-master”




         “repositories”: point to non-indexed, override existing or on-
                                the-fly packages

    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/rdohms/hero-superpackage"
        }       
    ]
N!.-C!"p#$r P'*4'/$
{
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "smarty/smarty",
                "version": "3.1.7",
                "dist": {
                    "url": "http://www.smarty.net/files/Smarty-3.1.7.zip",
                    "type": "zip"
                },
                "source": {
                    "url": "http://smarty-php.googlecode.com/svn/",
                    "type": "svn",
                    "reference": "tags/Smarty_3_1_7/distribution/"
                }
            }
        }
    ]
}
N!.-C!"p#$r P'*4'/$
{
    "repositories": “package”: on-the-fly package, injecting a composer.json
                     [
        {
            "type": "package",
            "package": {
                "name": "smarty/smarty",
                "version": "3.1.7",
                "dist": {
                     "url": "http://www.smarty.net/files/Smarty-3.1.7.zip",
                     "type": "zip"
                },
                "source": {
                     "url": "http://smarty-php.googlecode.com/svn/",
                     "type": "svn",
                     "reference": "tags/Smarty_3_1_7/distribution/"
                }
            }
        }
    ]
}
N!.-C!"p#$r P'*4'/$
{
    "repositories": “package”: on-the-fly package, injecting a composer.json
                     [
        {
            "type": "package",
            "package": {
                "name": "smarty/smarty",
                "version": "3.1.7",
                "dist": {
                     "url": "http://www.smarty.net/files/Smarty-3.1.7.zip",
                     "type": "zip"                                           SVN / Git
                },
                "source": {
                     "url": "http://smarty-php.googlecode.com/svn/",
                     "type": "svn",
                     "reference": "tags/Smarty_3_1_7/distribution/"
                }
            }
        }
    ]
}
I .$$- (+)0 PEAR p'*4'/$...
         No Problem!
{
    "repositories": [
        {
            "type": "pear",
            "url": "http://pear2.php.net"
        }
    ],
    "require": {
        "pear-pear2.php.net/PEAR2_Text_Markdown": "*",
        "pear-pear2/PEAR2_HTTP_Request": "*"
    }
}
{
    "repositories": [   “pear”: official PEAR and custom PEAR channels
        {
            "type": "pear",
            "url": "http://pear2.php.net"
        }
    ],
    "require": {
        "pear-pear2.php.net/PEAR2_Text_Markdown": "*",
        "pear-pear2/PEAR2_HTTP_Request": "*"
    }
}
{
    "repositories": [   “pear”: official PEAR and custom PEAR channels
        {
            "type": "pear",
            "url": "http://pear2.php.net"
        }
    ],
    "require": {
        "pear-pear2.php.net/PEAR2_Text_Markdown": "*",
        "pear-pear2/PEAR2_HTTP_Request": "*"
    }
}                Remember the prefix!
{
    "repositories": [   “pear”: official PEAR and custom PEAR channels
        {
            "type": "pear",
            "url": "http://pear2.php.net"
        }
    ],
    "require": {
        "pear-pear2.php.net/PEAR2_Text_Markdown": "*",
        "pear-pear2/PEAR2_HTTP_Request": "*"
    }
}                Remember the prefix!




                              !!   Warning: PEAR causes a overhead of requests
alias




replace   provide
alias

{
    "extra": {
        "branch-alias": {
            "dev-master": "1.0.x-dev"
        }
    },

    "require": {
        "monolog/monolog": "dev-bugfix as 1.0.x-dev"
    }
}




replace                                          provide
alias

{
    "extra": {
        "branch-alias": {
            "dev-master": "1.0.x-dev"
        }
    },

    "require": {
        "monolog/monolog": "dev-bugfix as 1.0.x-dev"
    }
}




replace                                          provide

  “replace”: allows you to
replace other packages, and
be used them in their place.
alias

{
    "extra": {
        "branch-alias": {
            "dev-master": "1.0.x-dev"
        }
    },

    "require": {
        "monolog/monolog": "dev-bugfix as 1.0.x-dev"
    }
}




replace                                          provide

  “replace”: allows you to                       “provide”: allows you to say
replace other packages, and                         a package provides a
be used them in their place.                            expectation.
1.-)./ ,!2r (2.$
I .$$- ' &)br'r, (+'( -!$0..
     Let me get that for you
http://packagist.org/
usage info




                        package info




versions
$ composer.phar search filter
$ composer.phar search filter



dms/dms-filter-bundle             :   DMS Filter Bundle, makes Annotation based ...
lexik/form-filter-bundle          :   This bundle aim to provide classes to build...
rollerworks/recordfilter-bundle   :   Record search-filtering bundle for Symfony
brikou/zend_filter                :   Zend Framework Filter Library
ext-filter                        :   The filter PHP extension
dms/dms-filter                    :   DMS Library, includes various bundles and ...
shtumi/useful-bundle              :   Symfony ShtumiUsefulBundle
$ composer.phar show dms/dms-filter-bundle
$ composer.phar show dms/dms-filter-bundle



name     :   dms/dms-filter-bundle
descrip. :   DMS Filter Bundle, makes Annotation based entity filtering available
in Symfony
keywords :   symfony, bundle, filter, dms
versions :   dev-master, v1.1.1, v1.1, 1.0.2, 1.0.1, 1.0.0
type     :   symfony-bundle
license :    MIT
source   :   [git] https://github.com/rdohms/DMSFilterBundle v1.1.1
dist     :   [zip] https://github.com/rdohms/DMSFilterBundle/zipball/v1.1.1 v1.1.1
names    :   dms/dms-filter-bundle

autoload
psr-0
DMSBundleFilterBundle => .

requires
php >=5.3.2
dms/dms-filter >=1.0.2
B2( ", r$p#)(!r, )0 pr)v'($!
  Get your own package repository
S'()0!
R!&&!2( ,!2r !w. S'()0
$ composer.phar create-project composer/satis
R!&&!2( ,!2r !w. S'()0
$ composer.phar create-project composer/satis
$ vi packages.json


  {
      "name": "My Repository",
      "homepage": "http://packages.example.org",
      "repositories": [
          { "type": "vcs", "url": "http://github.com/mycompany/privaterepo" },
          { "type": "vcs", "url": "http://svn.example.org/private/repo" },
          { "type": "vcs", "url": "http://github.com/mycompany/privaterepo2" }
      ],
      "require-all": true
  }
R!&&!2( ,!2r !w. S'()0
$ composer.phar create-project composer/satis
$ vi packages.json


  {
      "name": "My Repository",
      "homepage": "http://packages.example.org",
      "repositories": [
          { "type": "vcs", "url": "http://github.com/mycompany/privaterepo" },
          { "type": "vcs", "url": "http://svn.example.org/private/repo" },
          { "type": "vcs", "url": "http://github.com/mycompany/privaterepo2" }
      ],
      "require-all": true
  }



$ php bin/satis build config.json web/
U0)./ ,!2r !w. S'()0
{
    "repositories": [
        {
            "type": "composer",
            "url": "http://packages.yourdomain.net"
        }
    ],

    “require”: {
        “myvendor/mypackage”: “dev-master”
    }
}
U0)./ ,!2r !w. S'()0
{
    "repositories": [     “composer”: use this just like it was Packagist
        {
            "type": "composer",
            "url": "http://packages.yourdomain.net"
        }
    ],

    “require”: {
        “myvendor/mypackage”: “dev-master”
    }
}
W+$r$ 0+!2&- I /$( +$&p?

    http://getcomposer.org

 #composer on irc.freenode.org
%$ E&$v'(!r P)(*+
     Dependency Manager, consistent versions, per-project




               Ev$r,-', *!"p#)./
               install, update, lock and autoload




           Up/r'-)./ (! ' M'$0(r!
post-install, overriding, PEAR integration, developer environment




                 1.-)./ ,!2r (2.$
                       Satis and Packagist
Q2$0()!.0?

@rdohms

http://doh.ms

http://slides.doh.ms

More Related Content

What's hot

ZFConf 2012: Реализация доступа к СУБД IBM DB2 посредством встраиваемого SQL ...
ZFConf 2012: Реализация доступа к СУБД IBM DB2 посредством встраиваемого SQL ...ZFConf 2012: Реализация доступа к СУБД IBM DB2 посредством встраиваемого SQL ...
ZFConf 2012: Реализация доступа к СУБД IBM DB2 посредством встраиваемого SQL ...ZFConf Conference
 
Composer the right way - SunshinePHP
Composer the right way - SunshinePHPComposer the right way - SunshinePHP
Composer the right way - SunshinePHPRafael Dohms
 
Dependency management with Composer
Dependency management with ComposerDependency management with Composer
Dependency management with ComposerJason Grimes
 
Composer for Busy Developers - php|tek13
Composer for Busy Developers - php|tek13Composer for Busy Developers - php|tek13
Composer for Busy Developers - php|tek13Rafael Dohms
 
PHP & JavaScript & CSS Coding style
PHP & JavaScript & CSS Coding stylePHP & JavaScript & CSS Coding style
PHP & JavaScript & CSS Coding styleBo-Yi Wu
 
PHPCon China 2018 - 好孩子的 PHP 撰碼指南
PHPCon China 2018 - 好孩子的 PHP 撰碼指南PHPCon China 2018 - 好孩子的 PHP 撰碼指南
PHPCon China 2018 - 好孩子的 PHP 撰碼指南Shengyou Fan
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterZendCon
 
Crafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in RubyCrafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in RubyNikhil Mungel
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014biicode
 
Introducing Command Line Applications with Ruby
Introducing Command Line Applications with RubyIntroducing Command Line Applications with Ruby
Introducing Command Line Applications with RubyNikhil Mungel
 
Deployment Tactics
Deployment TacticsDeployment Tactics
Deployment TacticsIan Barber
 
Bootstrap your Cloud Infrastructure using puppet and hashicorp stack
Bootstrap your Cloud Infrastructure using puppet and hashicorp stackBootstrap your Cloud Infrastructure using puppet and hashicorp stack
Bootstrap your Cloud Infrastructure using puppet and hashicorp stackBram Vogelaar
 
Vagrant move over, here is Docker
Vagrant move over, here is DockerVagrant move over, here is Docker
Vagrant move over, here is DockerNick Belhomme
 
Laravel 4 package development
Laravel 4 package developmentLaravel 4 package development
Laravel 4 package developmentTihomir Opačić
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slidesharetomcopeland
 
OSDC 2014: Ole Michaelis & Sönke Rümpler: Make it SOLID - Software Architectu...
OSDC 2014: Ole Michaelis & Sönke Rümpler: Make it SOLID - Software Architectu...OSDC 2014: Ole Michaelis & Sönke Rümpler: Make it SOLID - Software Architectu...
OSDC 2014: Ole Michaelis & Sönke Rümpler: Make it SOLID - Software Architectu...NETWAYS
 
Zend\Expressive - höher, schneller, weiter
Zend\Expressive - höher, schneller, weiterZend\Expressive - höher, schneller, weiter
Zend\Expressive - höher, schneller, weiterRalf Eggert
 

What's hot (20)

Composer
ComposerComposer
Composer
 
ZFConf 2012: Реализация доступа к СУБД IBM DB2 посредством встраиваемого SQL ...
ZFConf 2012: Реализация доступа к СУБД IBM DB2 посредством встраиваемого SQL ...ZFConf 2012: Реализация доступа к СУБД IBM DB2 посредством встраиваемого SQL ...
ZFConf 2012: Реализация доступа к СУБД IBM DB2 посредством встраиваемого SQL ...
 
Composer the right way - SunshinePHP
Composer the right way - SunshinePHPComposer the right way - SunshinePHP
Composer the right way - SunshinePHP
 
Dependency management with Composer
Dependency management with ComposerDependency management with Composer
Dependency management with Composer
 
Composer for Busy Developers - php|tek13
Composer for Busy Developers - php|tek13Composer for Busy Developers - php|tek13
Composer for Busy Developers - php|tek13
 
PHP & JavaScript & CSS Coding style
PHP & JavaScript & CSS Coding stylePHP & JavaScript & CSS Coding style
PHP & JavaScript & CSS Coding style
 
PHPCon China 2018 - 好孩子的 PHP 撰碼指南
PHPCon China 2018 - 好孩子的 PHP 撰碼指南PHPCon China 2018 - 好孩子的 PHP 撰碼指南
PHPCon China 2018 - 好孩子的 PHP 撰碼指南
 
PECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life betterPECL Picks - Extensions to make your life better
PECL Picks - Extensions to make your life better
 
Crafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in RubyCrafting Beautiful CLI Applications in Ruby
Crafting Beautiful CLI Applications in Ruby
 
Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
 
Continuous Quality Assurance
Continuous Quality AssuranceContinuous Quality Assurance
Continuous Quality Assurance
 
Introducing Command Line Applications with Ruby
Introducing Command Line Applications with RubyIntroducing Command Line Applications with Ruby
Introducing Command Line Applications with Ruby
 
Deployment Tactics
Deployment TacticsDeployment Tactics
Deployment Tactics
 
Bootstrap your Cloud Infrastructure using puppet and hashicorp stack
Bootstrap your Cloud Infrastructure using puppet and hashicorp stackBootstrap your Cloud Infrastructure using puppet and hashicorp stack
Bootstrap your Cloud Infrastructure using puppet and hashicorp stack
 
Vagrant move over, here is Docker
Vagrant move over, here is DockerVagrant move over, here is Docker
Vagrant move over, here is Docker
 
Laravel 4 package development
Laravel 4 package developmentLaravel 4 package development
Laravel 4 package development
 
C++ for the Web
C++ for the WebC++ for the Web
C++ for the Web
 
Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshare
 
OSDC 2014: Ole Michaelis & Sönke Rümpler: Make it SOLID - Software Architectu...
OSDC 2014: Ole Michaelis & Sönke Rümpler: Make it SOLID - Software Architectu...OSDC 2014: Ole Michaelis & Sönke Rümpler: Make it SOLID - Software Architectu...
OSDC 2014: Ole Michaelis & Sönke Rümpler: Make it SOLID - Software Architectu...
 
Zend\Expressive - höher, schneller, weiter
Zend\Expressive - höher, schneller, weiterZend\Expressive - höher, schneller, weiter
Zend\Expressive - höher, schneller, weiter
 

Similar to Composer: putting dependencies on the score

May The Nodejs Be With You
May The Nodejs Be With YouMay The Nodejs Be With You
May The Nodejs Be With YouDalibor Gogic
 
The Modern Developer Toolbox
The Modern Developer ToolboxThe Modern Developer Toolbox
The Modern Developer ToolboxPablo Godel
 
Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Ben Hall
 
Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)Ben Hall
 
Toolbox of a Ruby Team
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby TeamArto Artnik
 
Subversionn Introduction at SuperMondays 2009-09-01
Subversionn Introduction at SuperMondays 2009-09-01Subversionn Introduction at SuperMondays 2009-09-01
Subversionn Introduction at SuperMondays 2009-09-01Alex Kavanagh
 
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...Puppet
 
Challenges of container configuration
Challenges of container configurationChallenges of container configuration
Challenges of container configurationlutter
 
Control your deployments with Capistrano
Control your deployments with CapistranoControl your deployments with Capistrano
Control your deployments with CapistranoRamazan K
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis OverviewLeo Lorieri
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierCarlos Sanchez
 
Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Bo-Yi Wu
 
Ruby on Rails and Docker - Why should I care?
Ruby on Rails and Docker - Why should I care?Ruby on Rails and Docker - Why should I care?
Ruby on Rails and Docker - Why should I care?Adam Hodowany
 
How to create your own hack environment
How to create your own hack environmentHow to create your own hack environment
How to create your own hack environmentSumedt Jitpukdebodin
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.catPablo Godel
 

Similar to Composer: putting dependencies on the score (20)

May The Nodejs Be With You
May The Nodejs Be With YouMay The Nodejs Be With You
May The Nodejs Be With You
 
The Modern Developer Toolbox
The Modern Developer ToolboxThe Modern Developer Toolbox
The Modern Developer Toolbox
 
Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)Running Docker in Development & Production (DevSum 2015)
Running Docker in Development & Production (DevSum 2015)
 
Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)
 
Toolbox of a Ruby Team
Toolbox of a Ruby TeamToolbox of a Ruby Team
Toolbox of a Ruby Team
 
Subversionn Introduction at SuperMondays 2009-09-01
Subversionn Introduction at SuperMondays 2009-09-01Subversionn Introduction at SuperMondays 2009-09-01
Subversionn Introduction at SuperMondays 2009-09-01
 
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
PuppetConf 2016: The Challenges with Container Configuration – David Lutterko...
 
Challenges of container configuration
Challenges of container configurationChallenges of container configuration
Challenges of container configuration
 
Control your deployments with Capistrano
Control your deployments with CapistranoControl your deployments with Capistrano
Control your deployments with Capistrano
 
Laravel Day / Deploy
Laravel Day / DeployLaravel Day / Deploy
Laravel Day / Deploy
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
 
EC2
EC2EC2
EC2
 
Elixir on Containers
Elixir on ContainersElixir on Containers
Elixir on Containers
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next Frontier
 
Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署
 
Docker Starter Pack
Docker Starter PackDocker Starter Pack
Docker Starter Pack
 
Ruby on Rails and Docker - Why should I care?
Ruby on Rails and Docker - Why should I care?Ruby on Rails and Docker - Why should I care?
Ruby on Rails and Docker - Why should I care?
 
How to create your own hack environment
How to create your own hack environmentHow to create your own hack environment
How to create your own hack environment
 
Deploying Symfony | symfony.cat
Deploying Symfony | symfony.catDeploying Symfony | symfony.cat
Deploying Symfony | symfony.cat
 
Git::Hooks
Git::HooksGit::Hooks
Git::Hooks
 

More from Rafael Dohms

The Individual Contributor Path - DPC2024
The Individual Contributor Path - DPC2024The Individual Contributor Path - DPC2024
The Individual Contributor Path - DPC2024Rafael Dohms
 
Application Metrics - IPC2023
Application Metrics - IPC2023Application Metrics - IPC2023
Application Metrics - IPC2023Rafael Dohms
 
How'd we get here? A guide to Architectural Decision Records
How'd we get here? A guide to Architectural Decision RecordsHow'd we get here? A guide to Architectural Decision Records
How'd we get here? A guide to Architectural Decision RecordsRafael Dohms
 
Architectural Decision Records - PHPConfBR
Architectural Decision Records - PHPConfBRArchitectural Decision Records - PHPConfBR
Architectural Decision Records - PHPConfBRRafael Dohms
 
Application Metrics (with Prometheus examples)
Application Metrics (with Prometheus examples)Application Metrics (with Prometheus examples)
Application Metrics (with Prometheus examples)Rafael Dohms
 
Application metrics - Confoo 2019
Application metrics - Confoo 2019Application metrics - Confoo 2019
Application metrics - Confoo 2019Rafael Dohms
 
Writing code you won’t hate tomorrow - PHPCE18
Writing code you won’t hate tomorrow - PHPCE18Writing code you won’t hate tomorrow - PHPCE18
Writing code you won’t hate tomorrow - PHPCE18Rafael Dohms
 
Application Metrics (with Prometheus examples) #PHPDD18
Application Metrics (with Prometheus examples) #PHPDD18Application Metrics (with Prometheus examples) #PHPDD18
Application Metrics (with Prometheus examples) #PHPDD18Rafael Dohms
 
Application metrics with Prometheus - DPC18
Application metrics with Prometheus - DPC18Application metrics with Prometheus - DPC18
Application metrics with Prometheus - DPC18Rafael Dohms
 
“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. - PHPKonf“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. - PHPKonfRafael Dohms
 
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...Rafael Dohms
 
Composer The Right Way - 010PHP
Composer The Right Way - 010PHPComposer The Right Way - 010PHP
Composer The Right Way - 010PHPRafael Dohms
 
Writing Code That Lasts - #Magento2Seminar, Utrecht
Writing Code That Lasts - #Magento2Seminar, UtrechtWriting Code That Lasts - #Magento2Seminar, Utrecht
Writing Code That Lasts - #Magento2Seminar, UtrechtRafael Dohms
 
Composer the Right Way - PHPSRB16
Composer the Right Way - PHPSRB16Composer the Right Way - PHPSRB16
Composer the Right Way - PHPSRB16Rafael Dohms
 
“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. - #PHPSRB16“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. - #PHPSRB16Rafael Dohms
 
Composer the Right Way - MM16NL
Composer the Right Way - MM16NLComposer the Right Way - MM16NL
Composer the Right Way - MM16NLRafael Dohms
 
Composer The Right Way - PHPUGMRN
Composer The Right Way - PHPUGMRNComposer The Right Way - PHPUGMRN
Composer The Right Way - PHPUGMRNRafael Dohms
 
Composer the Right Way - PHPBNL16
Composer the Right Way - PHPBNL16Composer the Right Way - PHPBNL16
Composer the Right Way - PHPBNL16Rafael Dohms
 
“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.
“Writing code that lasts” … or writing code you won’t hate tomorrow.Rafael Dohms
 
A Journey into your Lizard Brain - PHP Conference Brasil 2015
A Journey into your Lizard Brain - PHP Conference Brasil 2015A Journey into your Lizard Brain - PHP Conference Brasil 2015
A Journey into your Lizard Brain - PHP Conference Brasil 2015Rafael Dohms
 

More from Rafael Dohms (20)

The Individual Contributor Path - DPC2024
The Individual Contributor Path - DPC2024The Individual Contributor Path - DPC2024
The Individual Contributor Path - DPC2024
 
Application Metrics - IPC2023
Application Metrics - IPC2023Application Metrics - IPC2023
Application Metrics - IPC2023
 
How'd we get here? A guide to Architectural Decision Records
How'd we get here? A guide to Architectural Decision RecordsHow'd we get here? A guide to Architectural Decision Records
How'd we get here? A guide to Architectural Decision Records
 
Architectural Decision Records - PHPConfBR
Architectural Decision Records - PHPConfBRArchitectural Decision Records - PHPConfBR
Architectural Decision Records - PHPConfBR
 
Application Metrics (with Prometheus examples)
Application Metrics (with Prometheus examples)Application Metrics (with Prometheus examples)
Application Metrics (with Prometheus examples)
 
Application metrics - Confoo 2019
Application metrics - Confoo 2019Application metrics - Confoo 2019
Application metrics - Confoo 2019
 
Writing code you won’t hate tomorrow - PHPCE18
Writing code you won’t hate tomorrow - PHPCE18Writing code you won’t hate tomorrow - PHPCE18
Writing code you won’t hate tomorrow - PHPCE18
 
Application Metrics (with Prometheus examples) #PHPDD18
Application Metrics (with Prometheus examples) #PHPDD18Application Metrics (with Prometheus examples) #PHPDD18
Application Metrics (with Prometheus examples) #PHPDD18
 
Application metrics with Prometheus - DPC18
Application metrics with Prometheus - DPC18Application metrics with Prometheus - DPC18
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. - PHPKonf“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. - PHPKonf
 
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...
 
Composer The Right Way - 010PHP
Composer The Right Way - 010PHPComposer The Right Way - 010PHP
Composer The Right Way - 010PHP
 
Writing Code That Lasts - #Magento2Seminar, Utrecht
Writing Code That Lasts - #Magento2Seminar, UtrechtWriting Code That Lasts - #Magento2Seminar, Utrecht
Writing Code That Lasts - #Magento2Seminar, Utrecht
 
Composer the Right Way - PHPSRB16
Composer the Right Way - PHPSRB16Composer the Right Way - PHPSRB16
Composer the Right Way - PHPSRB16
 
“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. - #PHPSRB16“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. - #PHPSRB16
 
Composer the Right Way - MM16NL
Composer the Right Way - MM16NLComposer the Right Way - MM16NL
Composer the Right Way - MM16NL
 
Composer The Right Way - PHPUGMRN
Composer The Right Way - PHPUGMRNComposer The Right Way - PHPUGMRN
Composer The Right Way - PHPUGMRN
 
Composer the Right Way - PHPBNL16
Composer the Right Way - PHPBNL16Composer the Right Way - PHPBNL16
Composer the Right Way - PHPBNL16
 
“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.
“Writing code that lasts” … or writing code you won’t hate tomorrow.
 
A Journey into your Lizard Brain - PHP Conference Brasil 2015
A Journey into your Lizard Brain - PHP Conference Brasil 2015A Journey into your Lizard Brain - PHP Conference Brasil 2015
A Journey into your Lizard Brain - PHP Conference Brasil 2015
 

Recently uploaded

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 

Recently uploaded (20)

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 

Composer: putting dependencies on the score

  • 1. Rafael Dohms / @rdohms C!"p#$r Putting your dependencies on the score
  • 2. Rafael Dohms photo credit: Eli White @rdohms Evangelist, Speaker and Contributor. Developer at WEBclusive. Enabler at AmsterdamPHP.
  • 3. %$ E&$v'(!r P)(*+ a general introduction to Composer Ev$r,-', *!"p#)./ the basic stuff you need to know Up/r'-)./ (! ' M'$0(r! advanced features for more complex scenarios 1.-)./ ,!2r (2.$ discovering and sharing libraries
  • 5. per project system wide central repository spread out channels open acceptance strict standards
  • 6. Pr!b&$": I need my team and my deployments to use consistent versions of the dependencies of my project
  • 7. Pr!b&$": I need my team and my deployments to use consistent versions of the dependencies of my project S!&2()!.:
  • 8. Pr!b&$": I need my team and my deployments to use consistent versions of the dependencies of my project S!&2()!.: PEAR
  • 9. Pr!b&$": I need my team and my deployments to use consistent versions of the dependencies of my project S!&2()!.: PEAR SVN Externals
  • 10. Pr!b&$": I need my team and my deployments to use consistent versions of the dependencies of my project S!&2()!.: PEAR SVN Externals Git Submodules
  • 11. Pr!b&$": I need my team and my deployments to use consistent versions of the dependencies of my project S!&2()!.: PEAR SVN Externals Git Submodules vendor management script
  • 12. Pr!b&$": I need my team and my deployments to use consistent versions of the dependencies of my project S!&2()!.: PEAR SVN Externals Git Submodules vendor management script C!"p#$r!
  • 13. A per-project dependency manager that allows you to declare a consistent list of dependencies and versions for your application, as well as a consistent way of sharing your libraries and making them discoverable using packagist.org
  • 15. I.0('&&)./ C!"p#$r Local (embed) $ curl -s http://getcomposer.org/installer | php Global $ curl -s http://getcomposer.org/installer | php -- --install-dir=bin
  • 16. I.0('&&)./ C!"p#$r Local (embed) $ curl -s http://getcomposer.org/installer | php Global $ curl -s http://getcomposer.org/installer | php -- --install-dir=bin 3p: $ ln -s /usr/bin/composer.phar /usr/bin/composer
  • 18. I.0('&&)./ C!"p#$r $ composer.phar --version Composer version 6573fd3
  • 19. I.0('&&)./ C!"p#$r php $ composer.phar --version Composer version 6573fd3
  • 21. K$$p )( 2p-'($-! $ composer.phar self-update Updating to version 65e95ed. Downloading: 100%
  • 23. C!"p#$r 101 $ cd ~/dev/myproject
  • 24. C!"p#$r 101 $ cd ~/dev/myproject $ vim composer.json { "require": { "silex/silex": "1.0.*" }, "minimum-stability": "dev" }
  • 25. C!"p#$r 101 $ cd ~/dev/myproject $ vim composer.json note: project root { "require": { "silex/silex": "1.0.*" }, "minimum-stability": "dev" }
  • 26. C!"p#$r 101 $ cd ~/dev/myproject $ vim composer.json note: project root “require”: required packages and versions { "require": { adv. ex.: >=1.0.0,<1.2-dev "silex/silex": "1.0.*" }, "minimum-stability": "dev" }
  • 27. C!"p#$r 101 $ cd ~/dev/myproject $ vim composer.json note: project root “require”: required packages and versions { "require": { adv. ex.: >=1.0.0,<1.2-dev "silex/silex": "1.0.*" }, "minimum-stability": "dev" “minimum-stability”: if you only want stable } packages default: stable
  • 28. C!"p#$r 101 $ cd ~/dev/myproject $ vim composer.json note: project root “require”: required packages and versions { "require": { adv. ex.: >=1.0.0,<1.2-dev "silex/silex": "1.0.*" }, "minimum-stability": "dev" “minimum-stability”: if you only want stable } packages default: stable $ composer.phar install
  • 29. Installing dependencies - Installing pimple/pimple (dev-master) Cloning d2cfa2f02f50abef65c238747c753a5f6786f6be - Installing symfony/routing (dev-master) Cloning 6bca82c3ea0d42d750de4f49b22020dfd047dc0f - Installing symfony/http-foundation (dev-master) Cloning 498c2da9c3fecefc7e3b0add73621f3feb337ddd - Installing symfony/event-dispatcher (dev-master) Cloning b99b49760016467099f010aff7a5098861d49e09 - Installing symfony/http-kernel (dev-master) Cloning 7f671472f009231f9c1f5ec9b81fc6fbfcd9a955 - Installing silex/silex (dev-master) Cloning 18e248a277adb061602d2bcabe96011db1c76ec0 symfony/routing suggests installing symfony/config (dev-master) symfony/routing suggests installing symfony/yaml (dev-master) symfony/routing suggests installing doctrine/common (>=2.2,<2.4-dev) symfony/event-dispatcher suggests installing symfony/dependency-injection (dev-master) symfony/http-kernel suggests installing symfony/browser-kit (dev-master) symfony/http-kernel suggests installing symfony/class-loader (dev-master) symfony/http-kernel suggests installing symfony/config (dev-master) symfony/http-kernel suggests installing symfony/console (dev-master) symfony/http-kernel suggests installing symfony/dependency-injection (dev-master) symfony/http-kernel suggests installing symfony/finder (dev-master) silex/silex suggests installing symfony/browser-kit (2.1.*) silex/silex suggests installing symfony/css-selector (2.1.*) silex/silex suggests installing symfony/dom-crawler (2.1.*) Writing lock file Generating autoload files
  • 30. Installing dependencies - Installing pimple/pimple (dev-master) Cloning d2cfa2f02f50abef65c238747c753a5f6786f6be - Installing symfony/routing (dev-master) Cloning 6bca82c3ea0d42d750de4f49b22020dfd047dc0f - Installing symfony/http-foundation (dev-master) your dependency’s dependencies Cloning 498c2da9c3fecefc7e3b0add73621f3feb337ddd - Installing symfony/event-dispatcher (dev-master) Cloning b99b49760016467099f010aff7a5098861d49e09 - Installing symfony/http-kernel (dev-master) Cloning 7f671472f009231f9c1f5ec9b81fc6fbfcd9a955 - Installing silex/silex (dev-master) Cloning 18e248a277adb061602d2bcabe96011db1c76ec0 symfony/routing suggests installing symfony/config (dev-master) symfony/routing suggests installing symfony/yaml (dev-master) symfony/routing suggests installing doctrine/common (>=2.2,<2.4-dev) symfony/event-dispatcher suggests installing symfony/dependency-injection (dev-master) symfony/http-kernel suggests installing symfony/browser-kit (dev-master) symfony/http-kernel suggests installing symfony/class-loader (dev-master) symfony/http-kernel suggests installing symfony/config (dev-master) symfony/http-kernel suggests installing symfony/console (dev-master) symfony/http-kernel suggests installing symfony/dependency-injection (dev-master) symfony/http-kernel suggests installing symfony/finder (dev-master) silex/silex suggests installing symfony/browser-kit (2.1.*) silex/silex suggests installing symfony/css-selector (2.1.*) silex/silex suggests installing symfony/dom-crawler (2.1.*) Writing lock file Generating autoload files
  • 31. Installing dependencies - Installing pimple/pimple (dev-master) Cloning d2cfa2f02f50abef65c238747c753a5f6786f6be - Installing symfony/routing (dev-master) Cloning 6bca82c3ea0d42d750de4f49b22020dfd047dc0f - Installing symfony/http-foundation (dev-master) your dependency’s dependencies Cloning 498c2da9c3fecefc7e3b0add73621f3feb337ddd - Installing symfony/event-dispatcher (dev-master) Cloning b99b49760016467099f010aff7a5098861d49e09 - Installing symfony/http-kernel (dev-master) Cloning 7f671472f009231f9c1f5ec9b81fc6fbfcd9a955 - Installing silex/silex (dev-master) Cloning 18e248a277adb061602d2bcabe96011db1c76ec0 your dependency symfony/routing suggests installing symfony/config (dev-master) symfony/routing suggests installing symfony/yaml (dev-master) symfony/routing suggests installing doctrine/common (>=2.2,<2.4-dev) symfony/event-dispatcher suggests installing symfony/dependency-injection (dev-master) symfony/http-kernel suggests installing symfony/browser-kit (dev-master) symfony/http-kernel suggests installing symfony/class-loader (dev-master) symfony/http-kernel suggests installing symfony/config (dev-master) symfony/http-kernel suggests installing symfony/console (dev-master) symfony/http-kernel suggests installing symfony/dependency-injection (dev-master) symfony/http-kernel suggests installing symfony/finder (dev-master) silex/silex suggests installing symfony/browser-kit (2.1.*) silex/silex suggests installing symfony/css-selector (2.1.*) silex/silex suggests installing symfony/dom-crawler (2.1.*) Writing lock file Generating autoload files
  • 32. Installing dependencies - Installing pimple/pimple (dev-master) Cloning d2cfa2f02f50abef65c238747c753a5f6786f6be - Installing symfony/routing (dev-master) Cloning 6bca82c3ea0d42d750de4f49b22020dfd047dc0f - Installing symfony/http-foundation (dev-master) your dependency’s dependencies Cloning 498c2da9c3fecefc7e3b0add73621f3feb337ddd - Installing symfony/event-dispatcher (dev-master) Cloning b99b49760016467099f010aff7a5098861d49e09 - Installing symfony/http-kernel (dev-master) Cloning 7f671472f009231f9c1f5ec9b81fc6fbfcd9a955 - Installing silex/silex (dev-master) Cloning 18e248a277adb061602d2bcabe96011db1c76ec0 your dependency symfony/routing suggests installing symfony/config (dev-master) symfony/routing suggests installing symfony/yaml (dev-master) symfony/routing suggests installing doctrine/common (>=2.2,<2.4-dev) symfony/event-dispatcher suggests installing symfony/dependency-injection (dev-master) symfony/http-kernel suggests installing symfony/browser-kit (dev-master) symfony/http-kernel suggests installing symfony/class-loader (dev-master) symfony/http-kernel suggests installing symfony/config (dev-master) symfony/http-kernel suggests installing symfony/console (dev-master) symfony/http-kernel suggests installing symfony/dependency-injection (dev-master) symfony/http-kernel suggests installing symfony/finder (dev-master) silex/silex suggests installing symfony/browser-kit (2.1.*) silex/silex suggests installing symfony/css-selector (2.1.*) silex/silex suggests installing symfony/dom-crawler (2.1.*) suggestions of other packages, Writing lock file Generating autoload files for further features
  • 33. P)*42p (+$ ($"p!! Let Composer bootstrap you development
  • 34. B!!(0(r'pp)./ Pr!5$*(0 $ composer.phar create-project fabpot/silex-skeleton ~/dev/myproject
  • 35. B!!(0(r'pp)./ Pr!5$*(0 $ composer.phar create-project fabpot/silex-skeleton ~/dev/myproject Installing fabpot/silex-skeleton (dev-master cc19d406cf3cac253715db92d400992d4f3e1b52) - Installing fabpot/silex-skeleton (dev-master) Cloning master Created project in one-liner/ Installing dependencies - Installing pimple/pimple (dev-master) Cloning d2cfa2f02f50abef65c238747c753a5f6786f6be [...] symfony/routing suggests installing symfony/yaml (dev-master) [...] Writing lock file Generating autoload files
  • 36. B!!(0(r'pp)./ Pr!5$*(0 $ composer.phar create-project fabpot/silex-skeleton ~/dev/myproject Installing fabpot/silex-skeleton (dev-master cc19d406cf3cac253715db92d400992d4f3e1b52) - Installing fabpot/silex-skeleton (dev-master) Cloning master Created project in one-liner/ myproje ct/ Installing dependencies compose - Installing pimple/pimple (dev-master) r.json compose Cloning d2cfa2f02f50abef65c238747c753a5f6786f6be r.lock config/ [...] console / src/ symfony/routing suggests installing symfony/yaml (dev-master) templat [...] es/ vendor/ Writing lock file web/ Generating autoload files
  • 37. I w'.( (! *!.(r)b2($ ' pr!5$*( Composer can set that up for you.
  • 38. B!!(0(r'pp)./ C!.(r)b2()!.0 $ composer.phar create-project dms/dms --dev ~/dev/oss/dms
  • 39. B!!(0(r'pp)./ C!.(r)b2()!.0 gimme dev packages $ composer.phar create-project dms/dms --dev ~/dev/oss/dms
  • 40. B!!(0(r'pp)./ C!.(r)b2()!.0 gimme dev packages $ composer.phar create-project dms/dms --dev ~/dev/oss/dms     "require-dev": {         "symfony/symfony": ">=2.1-dev",         "doctrine/orm": "dev-master"     },
  • 41. B!!(0(r'pp)./ C!.(r)b2()!.0 gimme dev packages $ composer.phar create-project dms/dms --dev ~/dev/oss/dms     "require-dev": {         "symfony/symfony": ">=2.1-dev",         "doctrine/orm": "dev-master"     }, “require-dev”: only needed if you are going to contribute
  • 42. H!w -! I 6.-/&!'- (+$ 6&$0? PSR-0 and the modern autoloader
  • 43. Composer generates an autoload file for all your dependencies
  • 44. Composer generates an autoload file for all your dependencies vendor/autoload.php
  • 45. "autoload": {     "psr-0": { "MyNamespace": "<root>" }, "classmap": ["src/", "lib/", "Something.php"], "files": ["src/MyLibrary/functions.php"] },
  • 46. “autoload”: describes the autoloading needed for your library "autoload": {     "psr-0": { "MyNamespace": "<root>" }, "classmap": ["src/", "lib/", "Something.php"], "files": ["src/MyLibrary/functions.php"] },
  • 47. “autoload”: describes the autoloading needed for your library "autoload": {     "psr-0": { "MyNamespace": "<root>" }, “psr-0”: PSR-0 Compatible libraries "classmap": ["src/", "lib/", "Something.php"], "files": ["src/MyLibrary/functions.php"] },
  • 48. “autoload”: describes the autoloading needed for your library "autoload": {     "psr-0": { "MyNamespace": "<root>" }, “psr-0”: PSR-0 Compatible libraries “classmap”: Old PEAR packages and other "classmap": ["src/", "lib/", "Something.php"], libraries "files": ["src/MyLibrary/functions.php"] },
  • 49. “autoload”: describes the autoloading needed for your library "autoload": {     "psr-0": { "MyNamespace": "<root>" }, “psr-0”: PSR-0 Compatible libraries “classmap”: Old PEAR packages and other "classmap": ["src/", "lib/", "Something.php"], libraries "files": ["src/MyLibrary/functions.php"] “files”: for php functions or initializations },
  • 50. I.0('&&)./, 2p-'()./ '.- "!v)./ !. how does Composer guarantee consistency
  • 51.
  • 53. “composer.json”: metadata and list of your dependencies. composer.json
  • 54. “composer.json”: metadata and list of your dependencies. composer.json composer.lock
  • 55. “composer.json”: metadata and list of your dependencies. composer.json composer.lock “composer.lock”: existing dependencies and current commit hashes.
  • 57. update composer.json composer.lock
  • 58. update install composer.json composer.lock
  • 59. update install reads composer.json composer.lock
  • 60. update install reads composer.json composer.lock gets latest
  • 61. update install reads composer.json writes composer.lock gets latest
  • 62. update install reads reads composer.json writes composer.lock gets latest
  • 63. update install reads reads composer.json compares writes composer.lock gets latest
  • 64. update install reads reads composer.json compares writes composer.lock gets latest gets locked version
  • 65. D$v$&!p)./ '. App ). ' ($'"? Commit you composer.lock file into the repository, and use composer install.
  • 66. D$v$&!p)./ '. App ). ' ($'"? Commit you composer.lock file into the repository, and use composer install. will ensure everyone is on the same “page”
  • 67. I’" -$v$&!p)./ ' &)br'r,, +$&p! here are some fields you should care about
  • 68. { "name": "vendor-namespace/package-name", "type": "symfony-bundle", "description": "A sample package for examples", "keywords": ["php", "package"], "homepage": "http://doh.ms", "license": "MIT", "support": { "email": "support@mylib.com", "issues": "http://issues.lib.com" } "target-dir": "/folder/to/install", }
  • 69. “name”: this should be unique, pick a good one! { "name": "vendor-namespace/package-name", "type": "symfony-bundle", "description": "A sample package for examples", "keywords": ["php", "package"], "homepage": "http://doh.ms", "license": "MIT", "support": { "email": "support@mylib.com", "issues": "http://issues.lib.com" } "target-dir": "/folder/to/install", }
  • 70. “name”: this should be unique, pick a good one! { "name": "vendor-namespace/package-name", “type”: will be used for more advanced "type": "symfony-bundle", “custom”installs "description": "A sample package for examples", "keywords": ["php", "package"], "homepage": "http://doh.ms", "license": "MIT", "support": { "email": "support@mylib.com", "issues": "http://issues.lib.com" } "target-dir": "/folder/to/install", }
  • 71. “name”: this should be unique, pick a good one! { "name": "vendor-namespace/package-name", “type”: will be used for more advanced "type": "symfony-bundle", “custom”installs "description": "A sample package for examples", "keywords": ["php", "package"], "homepage": "http://doh.ms", "license": "MIT", “license”: very important! "support": { "email": "support@mylib.com", "issues": "http://issues.lib.com" } "target-dir": "/folder/to/install", }
  • 72. “name”: this should be unique, pick a good one! { "name": "vendor-namespace/package-name", “type”: will be used for more advanced "type": "symfony-bundle", “custom”installs "description": "A sample package for examples", "keywords": ["php", "package"], "homepage": "http://doh.ms", "license": "MIT", “license”: very important! "support": { "email": "support@mylib.com", “support”: point people the right way. "issues": "http://issues.lib.com" } "target-dir": "/folder/to/install", }
  • 73. “name”: this should be unique, pick a good one! { "name": "vendor-namespace/package-name", “type”: will be used for more advanced "type": "symfony-bundle", “custom”installs "description": "A sample package for examples", "keywords": ["php", "package"], "homepage": "http://doh.ms", "license": "MIT", “license”: very important! "support": { "email": "support@mylib.com", “support”: point people the right way. "issues": "http://issues.lib.com" } "target-dir": "/folder/to/install", } “target-dir”: great for installing sub-dir splits repositories ex: Symfony Bundles: /Acme/Bundle/MyBundle
  • 74. M, *!-$ )0 PHP 5.4 !.&,! managing system dependencies
  • 75. { "require": { "php": ">=5.3.3", "ext-ldap": "*" } }
  • 76. { “php”: PHP version. "require": { "php": ">=5.3.3", "ext-ldap": "*" } }
  • 77. { “php”: PHP version. "require": { "php": ">=5.3.3", "ext-ldap": "*" } } “ext-*”: Presence of selected extension
  • 78. Up/r'-)./ (! ' M'$0(r!
  • 79. B2( I .$$- ' 0p$*)6* v$r0)!. version modifiers to the rescue!
  • 80.
  • 82. “#<ref>”: Get this specific commit "acme/foo": "1.0.x-dev#3ebbe75"
  • 83. “#<ref>”: Get this specific commit "acme/foo": "1.0.x-dev#3ebbe75" "acme/foo": "@dev" "acme/foo": "1.0.*@beta"
  • 84. “#<ref>”: Get this specific commit "acme/foo": "1.0.x-dev#3ebbe75" "acme/foo": "@dev" "acme/foo": "1.0.*@beta" “@<state>”: Get a version outside your default stability
  • 85. I .$$- (! 7$*2($ ' f$w 0*r)p(0 how to automate tasks with Composer
  • 86.     "scripts": {         "post-install-cmd": [             "SensioBundleDistributionBundleComposerScriptHandler::buildBootstrap",             "SensioBundleDistributionBundleComposerScriptHandler::clearCache",             "SensioBundleDistributionBundleComposerScriptHandler::installAssets",             "SensioBundleDistributionBundleComposerScriptHandler::installRequirementsFile"         ],         "post-update-cmd": [             "SensioBundleDistributionBundleComposerScriptHandler::buildBootstrap",             "SensioBundleDistributionBundleComposerScriptHandler::clearCache",             "SensioBundleDistributionBundleComposerScriptHandler::installAssets",             "SensioBundleDistributionBundleComposerScriptHandler::installRequirementsFile"         ]     },
  • 87. “scripts”: allows you to run scripts at given moments     "scripts": {         "post-install-cmd": [             "SensioBundleDistributionBundleComposerScriptHandler::buildBootstrap",             "SensioBundleDistributionBundleComposerScriptHandler::clearCache",             "SensioBundleDistributionBundleComposerScriptHandler::installAssets",             "SensioBundleDistributionBundleComposerScriptHandler::installRequirementsFile"         ],         "post-update-cmd": [             "SensioBundleDistributionBundleComposerScriptHandler::buildBootstrap",             "SensioBundleDistributionBundleComposerScriptHandler::clearCache",             "SensioBundleDistributionBundleComposerScriptHandler::installAssets",             "SensioBundleDistributionBundleComposerScriptHandler::installRequirementsFile"         ]     },
  • 88. C20(!" R$p#)(!r)$0 !r .! C!"p#$r, w+'( .!w? Injecting Composer into wild packages
  • 93. “hero/superpackage”: “dev-master”     "repositories": [ { "type": "vcs", "url": "https://github.com/rdohms/hero-superpackage" }        ]
  • 94. “hero/superpackage”: “dev-master” “repositories”: point to non-indexed, override existing or on- the-fly packages     "repositories": [ { "type": "vcs", "url": "https://github.com/rdohms/hero-superpackage" }        ]
  • 95. N!.-C!"p#$r P'*4'/$ { "repositories": [ { "type": "package", "package": { "name": "smarty/smarty", "version": "3.1.7", "dist": { "url": "http://www.smarty.net/files/Smarty-3.1.7.zip", "type": "zip" }, "source": { "url": "http://smarty-php.googlecode.com/svn/", "type": "svn", "reference": "tags/Smarty_3_1_7/distribution/" } } } ] }
  • 96. N!.-C!"p#$r P'*4'/$ { "repositories": “package”: on-the-fly package, injecting a composer.json [ { "type": "package", "package": { "name": "smarty/smarty", "version": "3.1.7", "dist": { "url": "http://www.smarty.net/files/Smarty-3.1.7.zip", "type": "zip" }, "source": { "url": "http://smarty-php.googlecode.com/svn/", "type": "svn", "reference": "tags/Smarty_3_1_7/distribution/" } } } ] }
  • 97. N!.-C!"p#$r P'*4'/$ { "repositories": “package”: on-the-fly package, injecting a composer.json [ { "type": "package", "package": { "name": "smarty/smarty", "version": "3.1.7", "dist": { "url": "http://www.smarty.net/files/Smarty-3.1.7.zip", "type": "zip" SVN / Git }, "source": { "url": "http://smarty-php.googlecode.com/svn/", "type": "svn", "reference": "tags/Smarty_3_1_7/distribution/" } } } ] }
  • 98. I .$$- (+)0 PEAR p'*4'/$... No Problem!
  • 99. { "repositories": [ { "type": "pear", "url": "http://pear2.php.net" } ], "require": { "pear-pear2.php.net/PEAR2_Text_Markdown": "*", "pear-pear2/PEAR2_HTTP_Request": "*" } }
  • 100. { "repositories": [ “pear”: official PEAR and custom PEAR channels { "type": "pear", "url": "http://pear2.php.net" } ], "require": { "pear-pear2.php.net/PEAR2_Text_Markdown": "*", "pear-pear2/PEAR2_HTTP_Request": "*" } }
  • 101. { "repositories": [ “pear”: official PEAR and custom PEAR channels { "type": "pear", "url": "http://pear2.php.net" } ], "require": { "pear-pear2.php.net/PEAR2_Text_Markdown": "*", "pear-pear2/PEAR2_HTTP_Request": "*" } } Remember the prefix!
  • 102. { "repositories": [ “pear”: official PEAR and custom PEAR channels { "type": "pear", "url": "http://pear2.php.net" } ], "require": { "pear-pear2.php.net/PEAR2_Text_Markdown": "*", "pear-pear2/PEAR2_HTTP_Request": "*" } } Remember the prefix! !! Warning: PEAR causes a overhead of requests
  • 103. alias replace provide
  • 104. alias { "extra": { "branch-alias": { "dev-master": "1.0.x-dev" } }, "require": { "monolog/monolog": "dev-bugfix as 1.0.x-dev" } } replace provide
  • 105. alias { "extra": { "branch-alias": { "dev-master": "1.0.x-dev" } }, "require": { "monolog/monolog": "dev-bugfix as 1.0.x-dev" } } replace provide “replace”: allows you to replace other packages, and be used them in their place.
  • 106. alias { "extra": { "branch-alias": { "dev-master": "1.0.x-dev" } }, "require": { "monolog/monolog": "dev-bugfix as 1.0.x-dev" } } replace provide “replace”: allows you to “provide”: allows you to say replace other packages, and a package provides a be used them in their place. expectation.
  • 108. I .$$- ' &)br'r, (+'( -!$0.. Let me get that for you
  • 110. usage info package info versions
  • 112. $ composer.phar search filter dms/dms-filter-bundle : DMS Filter Bundle, makes Annotation based ... lexik/form-filter-bundle : This bundle aim to provide classes to build... rollerworks/recordfilter-bundle : Record search-filtering bundle for Symfony brikou/zend_filter : Zend Framework Filter Library ext-filter : The filter PHP extension dms/dms-filter : DMS Library, includes various bundles and ... shtumi/useful-bundle : Symfony ShtumiUsefulBundle
  • 113. $ composer.phar show dms/dms-filter-bundle
  • 114. $ composer.phar show dms/dms-filter-bundle name : dms/dms-filter-bundle descrip. : DMS Filter Bundle, makes Annotation based entity filtering available in Symfony keywords : symfony, bundle, filter, dms versions : dev-master, v1.1.1, v1.1, 1.0.2, 1.0.1, 1.0.0 type : symfony-bundle license : MIT source : [git] https://github.com/rdohms/DMSFilterBundle v1.1.1 dist : [zip] https://github.com/rdohms/DMSFilterBundle/zipball/v1.1.1 v1.1.1 names : dms/dms-filter-bundle autoload psr-0 DMSBundleFilterBundle => . requires php >=5.3.2 dms/dms-filter >=1.0.2
  • 115. B2( ", r$p#)(!r, )0 pr)v'($! Get your own package repository
  • 116. S'()0!
  • 117. R!&&!2( ,!2r !w. S'()0 $ composer.phar create-project composer/satis
  • 118. R!&&!2( ,!2r !w. S'()0 $ composer.phar create-project composer/satis $ vi packages.json { "name": "My Repository", "homepage": "http://packages.example.org", "repositories": [ { "type": "vcs", "url": "http://github.com/mycompany/privaterepo" }, { "type": "vcs", "url": "http://svn.example.org/private/repo" }, { "type": "vcs", "url": "http://github.com/mycompany/privaterepo2" } ], "require-all": true }
  • 119. R!&&!2( ,!2r !w. S'()0 $ composer.phar create-project composer/satis $ vi packages.json { "name": "My Repository", "homepage": "http://packages.example.org", "repositories": [ { "type": "vcs", "url": "http://github.com/mycompany/privaterepo" }, { "type": "vcs", "url": "http://svn.example.org/private/repo" }, { "type": "vcs", "url": "http://github.com/mycompany/privaterepo2" } ], "require-all": true } $ php bin/satis build config.json web/
  • 120. U0)./ ,!2r !w. S'()0 { "repositories": [ { "type": "composer", "url": "http://packages.yourdomain.net" } ], “require”: { “myvendor/mypackage”: “dev-master” } }
  • 121. U0)./ ,!2r !w. S'()0 { "repositories": [ “composer”: use this just like it was Packagist { "type": "composer", "url": "http://packages.yourdomain.net" } ], “require”: { “myvendor/mypackage”: “dev-master” } }
  • 122. W+$r$ 0+!2&- I /$( +$&p? http://getcomposer.org #composer on irc.freenode.org
  • 123. %$ E&$v'(!r P)(*+ Dependency Manager, consistent versions, per-project Ev$r,-', *!"p#)./ install, update, lock and autoload Up/r'-)./ (! ' M'$0(r! post-install, overriding, PEAR integration, developer environment 1.-)./ ,!2r (2.$ Satis and Packagist