Search code examples
amazon-web-servicescomposer-phpamazon-elastic-beanstalk

Why Can't I Run Composer Install on Deploy in AWS Elastic Beanstalk?


Apparently I'm missing something when trying to deploy my application in EB. I'm getting this error:

Instance deployment: You didn't include a 'composer.json' file in your source bundle. The deployment didn't install Composer dependencies.

I'm following the docs here and here. Here's a view of the file structure:

.
|____Buildfile
|____composer.json
|____composer.lock
|____index.php
|____api
| |____v1
| | |____index.php

My Buildfile:

01_composer_install: composer install

Any help or guidance would be much appreciated.

UPDATE: I tried adding the .platform hooks with no success. Same error. New tree structure:

.
|____.platform
| |____hooks
| | |____predeploy
| | | |____01_composer_install.sh
|____composer.json
|____composer.lock
|____index.php
|____api
| |____v1
| | |____index.php

01_composer_install.sh contents:

#!/bin/bash
composer install

Solution

  • Most likely your zip file (assuming you uploaded as zip) has a directory on top. That is, if you look at the zip structure it will be

    MyProject
    |
    --- composer.json
    

    Make sure that if you zip from File Explorer, you select files in the folder and not the folder itself. I see it happening all the time