A simple script to deploy PHP applications to AWS ElasticBeanstalk

v1.4.1 2018-01-19 19:24 UTC

This package is auto-updated.

Last update: 2024-04-11 01:59:17 UTC


A simple script to deploy PHP applications in a few minutes to ElasticBeanstalk.



composer global require "leroy-merlin-br/dployer=*@dev"

Global config for dployer

AWS config

You have 2 options to configure AWS:

  • Environment Variables
  • JSON configuration file

Environment Variables

You must fill the following environment variables.

  • DPLOYER_PROFILE : Your profile's name in AWS.
  • DPLOYER_REGION : Your region you want to deploy something.
  • DPLOYER_AWS_KEY : Your secret AWS key.

JSON Configuration File

  • Create the following configuration file: ~/.aws/config.json
    "includes": ["_aws"],
    "services": {
        "default_settings": {
            "params": {
                "profile": "my_profile",
                "region": "sa-east-1",
                "key": "YOURSUPERKEY",
                "secret": "YoUrSuPeRsEcReT"

AWS Bucket

Add the following line in the end of the ~/.bashrc file:

export DPLOYER_BUCKET=your-bucket-identifier-0-12345678


Inside the folder that you want to deploy, just run:

dployer deploy ApplicationName elasticbeanstalked-environment


You can use the following options:

  • -c (--config): Use a custom configuration file different from .dployer
  • -i (--interactive): Asks before run each command in configuration file
  • -v (--verbose): Display command outputs
  • -f (--force): Continue with deploy process even if a script exits with error

Project configuration

In order to optimize the deploy of your project, you can create a configuration file to keep application and environment variables. In addition, you gain some extra features, like: events to run the scripts that you want and options to copy extra files and delete some files before zip them.

Just create a .dployer file in project root dir.

Note: Once you have .dployer file with application and environment variables defined, you can just run the command as following:

dployer deploy

Sample .dployer

    "application": "ApplicationName",
    "environment": "my-environment",
    "scripts": {
        "init": "composer dumpautoload",
        "before-pack": [
            "gulp build --production"
        "before-deploy": [
            "echo 'Deploying new version'",
            "echo 'Another important command to run before deploy'"
        "finish": [
            "gulp clean",
            "echo 'Nicely done'"
    "copy-paths": [
    "exclude-paths": [


Dployer triggers 4 events in deploy flow:

  • init: Runs after initial validations and before any command of deploy
  • before-pack: Runs before create the zip file
  • before-deploy: Runs before create ElasticBeanstalk version and upload zip
  • finish: Runs after upload new version


The dployer just clone your current git branch inside a temp folder, then it creates a zip file. But sometimes, you want to deploy some files which are ignored by git (inside .gitignore file).

In this case, you can put these files/folders in copy-paths key in configuration file as demonstrated in sample section.


"copy-paths": [


In another case, sometimes you want to exclude some files/folders too.


"exclude-paths": [