Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Installation (for *nix platforms)

To install Composer globally (ie not for a specific project, which is recommended) run the following commands:

Code Block
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

OR

Code Block
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '55d6ead61b29c7bdee5cccfb50076874187bd9f21f65d8991d46ec5cc90518f447387fb9f76ebae1fbbacf329e583e30') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
mv composer.phar /usr/local/bin/composer

...

Composer helps manage various dependencies for PHP projects. The main focal point is a project's composer.json file, which stores information about all the dependencies Composer should install for a given project. Here's a sample from one of our projects:

 


Code Block
 {
    "require": {
        "behat/behat": "2.4.*@stable",
        "drupal/drupal-extension": "*",
        "sanpi/behatch-contexts": "*",
        "behat/mink": "*"
    },
    "minimum-stability": "dev",
    "config": {
        "bin-dir": "bin/"
    }
}

Running "composer install" in the directory with this composer.json file will install all of the requirements (stated in the "require" block) in a "vendors" file.