Menu
AWS Elastic Beanstalk
Developer Guide

Setting Up your PHP Development Environment

Set up a PHP development environment to test your application locally prior to deploying it to AWS Elastic Beanstalk. This topic outlines development environment setup steps and links to installation pages for useful tools.

For common setup steps and tools that apply to all languages, see Configuring your development environment for use with AWS Elastic Beanstalk

Installing PHP

Install PHP and some common extensions. If you don't have a preference, get the latest version. Depending on your platform and available package manager, the steps will vary.

On Amazon Linux, use yum:

$ sudo yum install php70 $ sudo yum install php70-mbstring $ sudo yum install php70-intl

On Ubuntu, use apt:

$ sudo apt install php-all-dev $ sudo apt install php-intl $ sudo apt install php-mbstring

On OS-X, use brew:

$ brew install php70 $ brew install php70-intl

On Windows 10, install the Windows Subsystem for Linux to get Ubuntu and install PHP with apt. For earlier versions, visit the download page at windows.php.net to get PHP, and read this page for information about extensions.

After installing PHP, reopen your terminal and run php --version to ensure that the new version has been installed and is the default.

Install Composer

Composer is a dependency manager for PHP. You can use it to install libraries, track your application's dependencies, and generate projects for popular PHP frameworks.

Install composer with the PHP script from getcomposer.org.

$ curl -s https://getcomposer.org/installer | php

The installer generates a PHAR file in the current directory. Move this file to a location in your environment PATH so that you can use it as an executable.

$ mv composer.phar ~/.local/bin/composer

Install libraries with the require command.

$ composer require twig/twig

Composer adds libraries that you install locally to your project's composer.json file. When you deploy your project code, Elastic Beanstalk uses Composer to install the libraries listed in this file on your environment's application instances.

If you run into issues installing Composer, visit the official documentation: https://getcomposer.org/

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.

Install the SDK for PHP with Composer.

$ composer require aws/aws-sdk-php

Visit the AWS SDK for PHP homepage for more information and installation instructions.

Installing an IDE or Text Editor

Integrated development environments (IDEs) provide a wide range of features that facilitate application development. If you haven't used an IDE for PHP development, try Eclipse and PHPStorm and see which works best for you.

Note

An IDE might add files to your project folder that you might not want to commit to source control. To prevent committing these files to source control, use .gitignore or your source control tool's equivalent.

If you just want to begin coding and don't need all of the features of an IDE, consider installing Sublime Text.