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
Prerequisites
- This article assumes you already have an Engine Yard account. If not, see Sign up for an Engine Yard Account.
- If you don't already have Composer installed on your local machine, you can get it on the Composer download site.
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
-
Create your composer.json file to declare your dependencies.
The composer.json file specifies required packages.
-
Verify that a composer.json file is present in the root of your git repository.
- Run
composer install
(on your local machine) to install the required packages and generate a composer.lock file. - Commit the composer.lock file to your git repository.
- In Engine Yard Cloud, click Tools > Dashboard.
- Select an environment by clicking the environment name.
- 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
- Navigate to the root of your git repo, where your composer.json file is.
- Run
composer update
(on your local machine) to update the required packages and re-generate a composer.lock file. - Commit the updated composer.lock file to your git repository.
- In Engine Yard Cloud, click Tools > Dashboard.
- Select an environment by clicking the environment name.
- 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.
Comments
Article is closed for comments.