Use Composer for PHP

This document describes how to use Composer for PHP on Engine Yard Cloud.

Composer is a dependency manager for PHP (similar to Bundler for Ruby apps). Composer allows developers to specify project dependencies in a composer.json file and then Composer automatically handles the rest.

Composer makes it easier to keep vendor libraries out of your repo, meaning that only application code goes in the git repository. It also makes maintaining the latest versions of all required libraries easier because you can simply run composer update to get the latest compatible packages.

Additionally, you can use Composer to manage Magento extensions. See Composer Installer for Magento for more information.

Get started with Composer on Engine Yard Cloud


Use Composer

When you deploy your PHP app, Engine Yard Cloud detects if you have a composer.lock file in your repo. If you do, then it runs composer install which takes the contents of your composer.lock file and downloads the required packages. Once Composer successfully installs all the packages and creates the autoload script for your application, Engine Yard Cloud removes the symlink to your previous deploy and replaces it with a link to the current deploy.

Engine Yard Cloud also ensures that you are always using the latest version of Composer by running composer self-update with each app deploy.

Important: We recommend testing in a staging environment before applying changes in a production environment.

To configure Composer for your PHP app

  1. Create your composer.json file to declare your dependencies.

    The composer.json file specifies required packages.

  2. Verify that a composer.json file is present in the root of your git repository.

  3. Run composer install (on your local machine) to install the required packages and generate a composer.lock file.
  4. Commit the composer.lock file to your git repository.
  5. In Engine Yard Cloud, click Tools > Dashboard.
  6. Select an environment by clicking the environment name.
  7. On the Environment page, click Deploy.

Update packages with Composer

Composer ensures the consistency of packages and package versions across Engine Yard Cloud environments. It also makes updating packages easier.

To update your packages

  1. Navigate to the root of your git repo, where your composer.json file is.
  2. Run composer update (on your local machine) to update the required packages and re-generate a composer.lock file.
  3. Commit the updated composer.lock file to your git repository.
  4. In Engine Yard Cloud, click Tools > Dashboard.
  5. Select an environment by clicking the environment name.
  6. On the Environment page, click Deploy.

Verify Composer

Here's how you can verify Composer in your environment.

To verify Composer

  • After deploying your app, ensure that there is a vendor/ folder in the root of the git repo.

    (If Composer fails, your app will likely fail also.)

More information

This table provides other resources related to Composer.

For more information about... See...
Composer in general Composer web site
Installing Composer Composer download site
Declaring dependencies Composer dependencies
PHP on Engine Yard Cloud Deploy Your PHP App on Engine Yard Cloud
Using Composer to manage Magento extensions Composer Installer for Magento

If you have feedback or questions about this page, add a comment below. If you need help, submit a ticket with Engine Yard Support.


Article is closed for comments.