Getting Started with Composer
Install Composer
Run this command in the root directory of your project:
Alternatively, you may run this in your command line:
Create the JSON file for your packages
Put a file named composer.json at the root of your project, containing your project dependencies:
Install Dependencies
Execute this in your project root.
Autoload Dependencies
Run this command in the root directory of your project:
php -r "readfile('https://getcomposer.org/installer');" > composer-setup.php
php -r "if (hash('SHA384', file_get_contents('composer-setup.php')) === '41e71d86b40f28e771d4bb662b997f79625196afcca95a5abf44391188c695c6c1456e16154c75a211d238cc3bc5cb47') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
Alternatively, you may run this in your command line:
curl -sS https://getcomposer.org/installer | php
Create the JSON file for your packages
Put a file named composer.json at the root of your project, containing your project dependencies:
{
"require": {
"vendor/package": "1.3.2",
"vendor/package2": "1.*",
"vendor/package3": "^2.0.3"
}
}
Install Dependencies
Execute this in your project root.
php composer.phar install
Autoload Dependencies
require 'vendor/autoload.php';
Comments
Post a Comment