From 264137ab581cb0aa950a17cd2d5220c2148745d7 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Tue, 10 Jul 2012 11:14:05 +0100 Subject: [PATCH] Fixed Twig example of Composer page. Also, commands don't need syntax. It's just a command. --- _includes/dependency-management.md | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/_includes/dependency-management.md b/_includes/dependency-management.md index bd67b65..d1685b7 100644 --- a/_includes/dependency-management.md +++ b/_includes/dependency-management.md @@ -12,7 +12,7 @@ There are already a lot of PHP libraries that are compatible with Composer, read 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 http://getcomposer.org/installer | php + curl -s http://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. @@ -28,37 +28,36 @@ Manually installing composer is an advanced technique; however, there are variou 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 http://getcomposer.org/composer.phar -o $HOME/local/bin/composer ; chmod +x $HOME/local/bin/composer + curl -s http://getcomposer.org/composer.phar -o $HOME/local/bin/composer + chmod +x $HOME/local/bin/composer -`$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. +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 + composer install ### How to Define and Install Dependencies First, create a `composer.json` file in the same directory as `composer.phar`. Here's an example that lists [Twig][2] as a project dependency. {% highlight json %} - { - "require": { - "twig/twig": ">=1.8.0,<2.0-dev" - } +{ + "require": { + "twig/twig": "1.8.*" } +} {% endhighlight %} Next, run this command from your project root directory. -{% highlight bash %} - > php composer.phar install -{% endhighlight %} + php composer.phar install This will download and install the project dependencies into a `vendors/` directory. Next, add this line to your application's primary PHP file; this will tell PHP to use Composer's autoloader for your project dependencies. {% highlight php %}