PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, March 7, 2022

[FIXED] AWS Elastic Beanstalk and Composer

 March 07, 2022     amazon-ec2, amazon-elastic-beanstalk, amazon-web-services, composer-php     No comments   

Issue

I have an application with Composer dependencies which I want to deploy to an Elastic Beanstalk container. However my composer.json file is not in the project root folder. My project root has the following structure:

- .ebextensions
- scripts
- www (Webroot)
  - composer.json

And I have set the document root to /www in the container configuration options. The issue is that I need to install composer on the box and run the composer install script to add the project dependencies. I understand that during a deploy EB will check to see if there is a composer.json file in the project root and install Composer but in this case my composer.json file is in a sub-directory.

I thought that could use .ebextenstions to add commands to install Composer and dependencies after the application has been deployed. I created a file .ebextensions/01-composer.config with the following container commands:

container_commands:
  01-install-composer:
    command: "curl -sS https://getcomposer.org/installer | php"
  02-install-packages:
    command: "php composer.phar install"
    cwd: "/var/app/current/www/"

But my app won't deploy with this configuration. Would appreciate some assistance to see where I am going wrong.

Thanks.


Solution

Composer is already installed default in Beanstalk's PHP AMI.

Also consider that container_commands are ran through '/var/app/ondeck' and not on current. Try something like this:

container_commands:
  01-install-packages:
    command: "composer.phar install -d /var/app/ondeck/www"


Answered By - Ker Ruben Ramos
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing