Updating/Adding packages via Composer

So you found a fantastic new bundle* package and want to add it to your Laravel 4 installation. Here’s what steps I just took to get it done.

* Bundles were used prior to Laravel 4. If you are looking at a bundle, it isn’t compatible with Laravel 4, by default.

The fantastic package that I just had to have was Imagine, an image processing package.

Depending on your server configuration you may or may not need to type php before any of the scripts below.

If it’s been a while since you’ve added a package to your site, it would be a good idea to make sure you have the latest and greatest Composer.

php composer.phar self-update

Navigate to your project’s laravel directory. It should be a directory with mostly just files related to composer. Files such as composer.phar, composer.json, etc. Once there, use your SSH text editor of choice to edit composer.json. For me, it was this

vi composer.json

Per the instructions at Imagine’s github, you need to update your composer.json as follows:

{
  "require": {
    "orchestra/imagine": "2.3.*@dev"
  }
}

In my case, I already had something in my composer.json so it ended up looking like this:

{
  "require": {
    "monolog/monolog": "1.2.*",
    "orchestra/imagine": "2.3.*@dev"
  }
}

Once that is saved, you can update your Laravel installation via this:

php composer.phar update

For further reading, feel free to check out Composer in more detail at https://getcomposer.org/doc/01-basic-usage.md

Leave a Reply

Your email address will not be published. Required fields are marked *