AWS Security ChangesHomeSearch

AWS elasticbeanstalk documentation change

Service: elasticbeanstalk · 2025-06-07 · Documentation low

File: elasticbeanstalk/latest/dg/create_deploy_PHP.container.md

Summary

Added documentation sections for installing AWS SDK for PHP, dependency management, Composer updates, and php.ini configuration. Updated platform branch references and restructured content.

Security assessment

Changes focus on feature documentation and best practices for PHP environment configuration. No direct security vulnerabilities or security-specific mitigations are mentioned. The Composer update warning relates to deployment reliability rather than security.

Diff

diff --git a/elasticbeanstalk/latest/dg/create_deploy_PHP.container.md b/elasticbeanstalk/latest/dg/create_deploy_PHP.container.md
index 7bd5cb906..e237558fd 100644
--- a//elasticbeanstalk/latest/dg/create_deploy_PHP.container.md
+++ b//elasticbeanstalk/latest/dg/create_deploy_PHP.container.md
@@ -5 +5 @@
-Considerations for PHP 8.1 on Amazon Linux 2Configuring your PHP environmentNamespaces for configuration
+Installing the AWS SDK for PHPConsiderations for PHP 8.1 on Amazon Linux 2Configuring your PHP environmentNamespaces for configurationInstalling dependenciesUpdating ComposerExtending php.ini
@@ -9 +9 @@ Considerations for PHP 8.1 on Amazon Linux 2Configuring your PHP environmentName
-This topic describes how to configure, build, and run your PHP applications on Elastic Beanstalk.
+AWS Elastic Beanstalk provides and supports various **platform branches** for different versions of PHP. The platforms support PHP web applications that run stand-alone or under Composer. See [PHP](https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html#platforms-supported.PHP) in the _AWS Elastic Beanstalk Platforms_ document for a full list of supported platform branches.
@@ -11,3 +11 @@ This topic describes how to configure, build, and run your PHP applications on E
-AWS Elastic Beanstalk supports a number of platform branches for different versions of the PHP programming language. These platforms support PHP web applications that can run alone or under Composer. See [PHP](https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html#platforms-supported.PHP) in the _AWS Elastic Beanstalk Platforms_ document for a full list of supported platform branches.
-
-Elastic Beanstalk provides [configuration options](./command-options.html) that you can use to customize the software that runs on the EC2 instances in your Elastic Beanstalk environment. You can [configure environment variables](./environments-cfg-softwaresettings.html#environments-cfg-softwaresettings-console) required by your application, enable log rotation to Amazon S3, map folders in your application source that contain static files to paths served by the proxy server, and set common PHP initialization settings.
+Elastic Beanstalk provides [configuration options](./command-options.html) that you can use to customize the software that runs on the Amazon EC2 instances in your Elastic Beanstalk environment. You can [configure environment variables](./environments-cfg-softwaresettings.html#environments-cfg-softwaresettings-console) required by your application, enable log rotation to Amazon S3, map folders in your application source that contain static files to paths served by the proxy server, and set common PHP initialization settings.
@@ -19 +17 @@ To save settings in your source code, you can include [configuration files](./eb
-If you use Composer, you can [include a composer.json file](./php-configuration-composer.html) in your source bundle to install packages during deployment.
+If you use Composer, you can include a composer.json file in your source bundle to install packages during deployment.
@@ -21 +19 @@ If you use Composer, you can [include a composer.json file](./php-configuration-
-For advanced PHP configuration and PHP settings that are not provided as configuration options, you can [use configuration files to provide an INI file](./php-configuration-phpini.html) that can extend and override the default settings applied by Elastic Beanstalk, or install additional extensions.
+For advanced PHP configuration and PHP settings that are not provided as configuration options, you can use configuration files to provide an INI file that can extend and override the default settings applied by Elastic Beanstalk, or install additional extensions.
@@ -26,0 +25,30 @@ For details about the various ways you can extend an Elastic Beanstalk Linux-bas
+###### PHP platform topics
+
+  * Installing the AWS SDK for PHP
+
+  * Considerations for PHP 8.1 on Amazon Linux 2
+
+  * Configuring your PHP environment
+
+  * Namespaces for configuration
+
+  * Installing dependencies
+
+  * Updating Composer
+
+  * Extending php.ini
+
+
+
+
+## Installing the AWS SDK for PHP
+
+If you need to manage AWS resources from within your application, install the AWS SDK for PHP. For example, with the SDK for PHP, you can use Amazon DynamoDB (DynamoDB) to store user and session information without creating a relational database.
+
+To install the SDK for PHP with Composer
+    
+    
+    $ composer require aws/aws-sdk-php
+
+For more information, see the [AWS SDK for PHP](https://aws.amazon.com/sdk-for-php/) homepage. For instructions, see [ Install the AWS SDK for PHP](https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/getting-started_installation.html).
+
@@ -149,4 +176,0 @@ You can use the Elastic Beanstalk console to enable log rotation to Amazon S3, c
-###### Note
-
-If you have many environments, use the search bar to filter the environment list.
-
@@ -246,0 +271,100 @@ Elastic Beanstalk provides many configuration options for customizing your envir
+## Installing your Elastic Beanstalk PHP application's dependencies
+
+This topic describes how to configure you application to install other PHP packages that it requires. Your application might have dependencies on other PHP packages. You can configure your application to install these dependencies on the environment's Amazon Elastic Compute Cloud (Amazon EC2) instances. Alternatively, you can include your application's dependencies in the source bundle and deploy them with the application. The following section discuss both of these ways.
+
+### Use a Composer file to install dependencies on instances
+
+Use a `composer.json` file in the root of your project source to use composer to install packages that your application requires on your environment's Amazon EC2 instances.
+
+###### Example composer.json
+    
+    
+    {
+        "require": {
+            "monolog/monolog": "1.0.*"
+        }
+    }
+
+When a `composer.json` file is present, Elastic Beanstalk runs `composer.phar install` to install dependencies. You can add options to append to the command by setting the composer_options option in the `aws:elasticbeanstalk:container:php:phpini` namespace.
+
+### Include dependencies in source bundle
+
+If your application has a large number of dependencies, installing them might take a long time. This can increase deployment and scaling operations, because dependencies are installed on every new instance.
+
+To avoid the negative impact on deployment time, use Composer in your development environment to resolve dependencies and install them into the `vendor` folder.
+
+###### To include dependencies in your application source bundle
+
+  1. Run the following command:
+    
+        % composer install
+
+  2. Include the generated `vendor` folder in the root of your application source bundle.
+
+
+
+
+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.
+
+## Updating Composer on Elastic Beanstalk
+
+This topic describes how to configure Elastic Beanstalk to keep Composer up to date. You may have to update Composer if you see an error when you try to install packages with a Composer file, or if you're unable to use the latest platform version. Between platform updates, you can update Composer in your environment instances through the use of configuration files in your [.ebextensions](./ebextensions.html) folder.
+
+You can self-update Composer with the following configuration.
+    
+    
+    commands:
+      01updateComposer:
+        command: /usr/bin/composer.phar self-update 2.7.0
+
+The following [option setting](./command-options-general.html#command-options-general-elasticbeanstalkapplicationenvironment) sets the `COMPOSER_HOME` environment variable, which configures the location of the Composer cache.
+    
+    
+    option_settings:
+      - namespace: aws:elasticbeanstalk:application:environment
+        option_name: COMPOSER_HOME
+        value: /home/webapp/composer-home
+
+You can combine both of these in the same configuration file in your `.ebextensions` folder.
+
+###### Example .ebextensions/composer.config
+    
+    
+    commands:
+      01updateComposer:
+        command: /usr/bin/composer.phar self-update 2.7.0
+        
+    option_settings:
+      - namespace: aws:elasticbeanstalk:application:environment
+        option_name: COMPOSER_HOME
+        value: /home/webapp/composer-home
+
+###### Note
+
+Due to updates to the Composer installation in the [February 22, 2024](https://docs.aws.amazon.com/elasticbeanstalk/latest/relnotes/release-2024-02-22-al2023.html), AL2023 platform release and the [February 28, 2024](https://docs.aws.amazon.com/elasticbeanstalk/latest/relnotes/release-2024-02-28-al2.html), AL2 platform release, the Composer self-update may fail if `COMPOSER_HOME` is set when the self-update executes. 
+
+The following combined commands will fail to execute: `export COMPOSER_HOME=/home/webapp/composer-home && /usr/bin/composer.phar self-update 2.7.0`
+
+However, the previous example will work. In the previous example, the option setting for `COMPOSER_HOME` will not be passed to the `01updateComposer` execution, and it will not be set when the self-update command executes.
+
+###### Important
+
+If you omit the version number from the `composer.phar self-update` command, Composer will update to the latest version available every time you deploy your source code, and when new instances are provisioned by Auto Scaling. This could cause scaling operations and deployments to fail if a version of Composer is released that is incompatible with your application.
+
+For more information about the Elastic Beanstalk PHP Platforms, including the version of Composer, see [PHP platform versions](https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html#platforms-supported.PHP) in the document _AWS Elastic Beanstalk Platforms_.
+
+## Extending php.ini in your Elastic Beanstalk configuration
+
+Use a configuration file with a `files` block to add a `.ini` file to `/etc/php.d/` on the instances in your environment. The main configuration file, `php.ini`, pulls in settings from files in this folder in alphabetical order. Many extensions are enabled by default by files in this folder.
+
+###### Example .ebextensions/mongo.config
+    
+    
+    files:
+      "/etc/php.d/99mongo.ini":
+        mode: "000755"
+        owner: root
+        group: root
+        content: |
+          extension=mongo.so
+
@@ -253 +377 @@ To use the Amazon Web Services Documentation, Javascript must be enabled. Please
-Development environment
+QuickStart for PHP
@@ -255 +379 @@ Development environment
-Installing dependencies
+Advanced examples