Leveraging Composer

No need to explain this anymore: Composer is the defacto standard to handle PHP application dependencies, as well as providing mechanisms to keep them up2date. Learn how to integrate Composer into your development workflow with fortrabbit.

Use Git deployment with Composer

TLDR; Just git push and you are good to go.

Local         fortrabbit deploy service           Your fortrabbit App
┌────────┐    ┌────────────┐  ┌────────────┐      ┌──────────────┐
│        │    │            │  │            │      │              │
│  Git   ├────▶  Git repo  ├──▶  Composer  ├──────▶   Webspace   │
│        │    │            │  │            │      │              │
└────────┘    └────────────┘  └────────────┘      └──────────────┘

The above drawing illustrates the fortrabbit architecture. When you deploy with Git, Composer will run automatically along within the deployment process.

The vendor folder should NOT be in Git > make sure that folder ins included in your .gitignore file. This directory is created by Composer within in your project locally and contains all the packages you are using locally.

Make sure that both the composer.lock file and the composer.json file are present and part of Git.

The deployment build process executes composer install (not update) to make sure that exactly the packages your App requires are installed.

Composer in the deployment file

You can fine tune your deployment behavior and aspects of Composer in the deployment file. See the options withunder the composer: keyword here.

Alternative locations

If your composer.json and composer.lock file are not on top level, then they will be ignored by the deployment. However, you can use the pre directive from the deployment file to setup a custom composer run in a different directory.

Following an example which assumes that your composer.* files are within the folder sub-folder:

fortrabbit.yml

version: 2

# execute alternate composer run before anything
pre: composer-run.php

# makre sure the new vendor folder is sustained during deploys
sustained:
  - sub-folder/vendor

composer-run.php

<?php

chdir("sub-folder");
exec("composer install");

Private repositories in Composer

You need to add the private repositories into your composer.json file? Read on here.

Composer from SSH

Universal Apps only: While we recommend to leverage Composer with Git deployment (see above), you can also execute Composer when logged in via SSH. Composer is pre-installed.

$ ssh {{ssh-user}}@deploy.{{region}}.frbit.com
$ composer install

This way Composer will be executed within your Apps web delivery environment, which is not optimized for such tasks. Please don't use Composer update as this might cause Composer to hit the Apps memory limits.

Further readings

Need individual help?

Get support › Learn about Company plans ›

Looking for an old article?

See the full list of articles ›

Found an error?

Contribute on GitHub ›