skip to Main Content

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

2

Answers


  1. 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

    Login or Signup to reply.
  2. You don’t need to run composer install manually. When a composer.json file is present, Elastic Beanstalk runs composer.phar install to install dependencies for you. And, when Elastic Beanstalk finds a vendor folder on the instance, it ignores the composer.json file (even if it exists). Your application then uses dependencies from the vendor folder.

    Source: Installing your application’s dependencies

    Further, in case you want to sets custom options to use when installing dependencies using Composer through composer.phar install, you can defines composer_options in the aws:elasticbeanstalk:container:php:phpini namespace in the configuration file of .ebextensions. For example:-
    .ebextensions/php-settings.config

    option_settings:
      aws:elasticbeanstalk:container:php:phpini:
        document_root: /public
        memory_limit: 128M
        zlib.output_compression: "Off"
        allow_url_fopen: "On"
        display_errors: "Off"
        max_execution_time: 60
        composer_options: vendor/package
    

    sources:

    Regarding the error, as you are trying to execute composer install with buildfile and hooks, it might not be running at the root of your application source code so it couldn’t find the composer.json file, so you might need to specify the absolute path of your composer.json with composer install, although I’m not very much sure on this part.

    I hope this helps.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search