I am trying to deploy a Laravel app to Elastic Beanstalk. I have changed the .ebextensions folder for the .platform folder and am using hooks.
The app is a Laravel 12 app using AWS's PHP 8.4 running on 64bit Amazon Linux 2023/4.6.1 platform.
Every time I try and deploy this app it seems like I am getting depreciation errors on the side of composer. To help with this, I added a "prebuild" folder inside .platform with instructions to download and install a new version of composer instead of defaulting to the one already cooked into the server. The file in "prebuild" is called "00_install_composer.sh" and looks like this:
#!/bin/bash
echo "-----> [prebuild] Starting Composer install process"
cd /var/app/staging
# Rename composer.json to avoid Elastic Beanstalk's default Composer step
if [ -f "composer.json" ]; then
echo "-----> [prebuild] Renaming composer.json to skip default EB Composer"
mv composer.json composer.json.bak
fi
# Download latest Composer
EXPECTED_SIGNATURE=$(curl -s https://composer.github.io/installer.sig)
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE=$(php -r "echo hash_file('sha384', 'composer-setup.php');")
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]; then
echo "ERROR: Invalid Composer installer signature"
rm composer-setup.php
exit 1
fi
php composer-setup.php --install-dir=/var/app/staging --filename=composer
rm composer-setup.php
# Restore composer.json
if [ -f "composer.json.bak" ]; then
echo "-----> [prebuild] Restoring composer.json"
mv composer.json.bak composer.json
fi
echo "-----> [prebuild] Composer install complete"
The issue is that after putting this file in place, I see in the logs that there are line items saying that the file should be run but then it seems that the server just continues on with its own pre-baked version of composer. Here are the log lines:
2025/05/13 16:05:57.845528 [INFO] Running script: .platform/hooks/prebuild/00_install_composer.sh
2025/05/13 16:05:58.571375 [INFO] Finished running scripts in /var/app/staging/.platform/hooks/prebuild
2025/05/13 16:05:58.571384 [INFO] Executing instruction: Install composer dependencies
2025/05/13 16:05:58.571400 [INFO] installing composer dependencies...
2025/05/13 16:05:58.571408 [INFO] Changing ownership of staging dir...
2025/05/13 16:05:58.582769 [INFO] Running command: /bin/su webapp -c composer.phar install --no-ansi --no-interaction
2025/05/13 16:06:14.187215 [INFO]
Deprecated: Composer\Console\Application::run(): Implicitly marking parameter $input as nullable is deprecated, the explicit nullable type must be used instead in phar:///usr/local/composer.phar/src/Composer/Console/Application.php on line 107
Deprecated: Composer\Console\Application::run(): Implicitly marking parameter $output as nullable is deprecated, the explicit nullable type must be used instead in phar:///usr/local/composer.phar/src/Composer/Console/Application.php on line 107
Deprecated: Symfony\Component\Console\Application::run(): Implicitly marking parameter $input as nullable is deprecated, the explicit nullable type must be used instead in phar:///usr/local/composer.phar/vendor/symfony/console/Application.php on line 103
Any idea how to handle this? I have no idea how to get a compatible version of composer up and running.
Thanks!
/bin/su webapp -c /var/app/staging/composer.phar ...(or maybe just/bin/su webapp -c ./composer.phar ...since I guess you are already in the correct directory)./usr/local/composer.pharis run, why not move your own instance ofcomposer.pharto that exact location? Which version of Composer does your image use initially?