Installing Composer dependencies

Hooks on Amezmo are simply bash script files located in the top level .amezmo directory. Use the .amezmo/after.pull hook to install Composer dependencies. Be sure to commit your composer.lock files to source control in order to speed up package installation.

Your application directory should have the .amezmo directory created as shown below.


# This is your application directory structure.
.
├── .amezmo
│   ├── after.pull
├── app
├── storage
├── public
├── .env


#!/bin/bash

# Path to this script: <your repo>/.amezmo/after.pull
set -e;

# RELEASE_ID is a predfined variable that
# Amezmo sets upon executing this script
echo "Running composer install for release (${RELEASE_ID})";

composer \
    --no-ansi \
    --no-interaction \
    --optimize-autoloader \
    --no-progress \
    --no-dev \
    --profile \
    install

# Uncomment if using Laravel
# php artisan migrate --no-interaction --no-ansi --force;

# Uncomment if you have NPM packages
# npm install;

Composer and NPM is setup for you out of the box when you launch an instance. If you're not commiting your vendor or node_modules directory to source control, then you can install your dependencies with a deployment hook.

Otherwise, if you're uploading your application, use .amezmo/after.upload hook to install Composer and NPM dependencies.

Using Hooks to Install Dependencies

Deployment hooks are files defined under the .amezmo directory inside your root directory of your application. You must create this directory and create deployment scripts inside this directory.

It's important that your script runs in non-interactive mode in order to prevent your deployment from failing. Deployment hooks currerntly have a 5 minute execution limit. We recommend using the following script for installing dependencies with composer. See below for a working deployment hook example.

Resources

  • The demo project provides more examples of deployment hooks
Need support?

We're always happy to help with either application or infrastructure questions Always feel free to reach out to us on Twitter, or contact support.

Subscribe