From e9a27625f20978bf0330820ea3b6c11a62079e1b Mon Sep 17 00:00:00 2001 From: johnstevenson Date: Wed, 26 Mar 2014 17:34:43 +0000 Subject: [PATCH] Add Windows installer --- _posts/04-02-01-Composer-and-Packagist.md | 35 ++++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/_posts/04-02-01-Composer-and-Packagist.md b/_posts/04-02-01-Composer-and-Packagist.md index 84d535b..9f3fa27 100644 --- a/_posts/04-02-01-Composer-and-Packagist.md +++ b/_posts/04-02-01-Composer-and-Packagist.md @@ -9,12 +9,39 @@ Composer is a **brilliant** dependency manager for PHP. List your project's depe There are already a lot of PHP libraries that are compatible with Composer, ready to be used in your project. These "packages" are listed on [Packagist][1], the official repository for Composer-compatible PHP libraries. -### Installing Composer -Composer is a single file called `composer.phar`, which is a PHP binary archive. It can either be installed locally in each of your project directories or in a single global location that is in your `$PATH` environment variable. The global method is recommended because it enables you to run it from your current working directory with the command `composer`. So when you come across documentation that states to run Composer as `php composer.phar install`, you can substitute that with: +### How to Install Composer + +You can install Composer locally (in your current working directory; though this is no longer recommended) or globally (e.g. /usr/local/bin). Let's assume you want to install Composer locally. From your project's root directory: + + curl -s https://getcomposer.org/installer | php + +This will download `composer.phar` (a PHP binary archive). You can run this with `php` to manage your project dependencies. Please Note: If you pipe downloaded code directly into an interpreter, please read the code online first to confirm it is safe. + +#### Installing on Windows +For Windows users the easiest way to get up and running is to use the [ComposerSetup][6] installer, which performs a global install and sets up your `$PATH` so that you can just call `composer` from any directory in your command line. + +### How to Install Composer (manually) + +Manually installing Composer is an advanced technique; however, there are various reasons why a developer might prefer this method vs. using the interactive installation routine. The interactive installation checks your PHP installation to ensure that: + +- a sufficient version of PHP is being used +- `.phar` files can be executed correctly +- certain directory permissions are sufficient +- certain problematic extensions are not loaded +- certain `php.ini` settings are set + +Since a manual installation performs none of these checks, you have to decide whether the trade-off is worth it for you. As such, below is how to obtain Composer manually: + + curl -s https://getcomposer.org/composer.phar -o $HOME/local/bin/composer + chmod +x $HOME/local/bin/composer + +The path `$HOME/local/bin` (or a directory of your choice) should be in your `$PATH` environment variable. This will result in a `composer` command being available. + +When you come across documentation that states to run Composer as `php composer.phar install`, you can substitute that with: composer install - -Detailed [installation instructions][5] can be found in the Composer documentation. For Windows users the easiest way to get up and running is to use the [ComposerSetup][6] installer. This section will assume you have installed Composer globally. + +This section will assume you have installed composer globally. ### How to Define and Install Dependencies