Can we use PHP with Oracle database

Adding an Amazon RDS DB Instance to the PHP Application Environment

You can use an Amazon Relational Database Service (Amazon RDS) DB instance to store data that has been collected and modified by your application. The database can be attached to your environment and managed by Elastic Beanstalk, or it can be created and managed externally.

The first time you use Amazon RDS, add a DB instance to a test environment using the Elastic Beanstalk console and see if the application can connect to it.

To connect to a database, you add the driver to the application, load the driver class into your code, and create a connection object with the environment properties provided by Elastic Beanstalk. The configuration and connection code depend on the database engine and framework you are using.

For learning purposes or test environments, you can use Elastic Beanstalk to add a DB instance.

For production environments, you can create a DB instance outside of your Elastic Beanstalk environment to decouple your environmental resources from your database resources. This way, when you exit your environment, the DB instance is not deleted. With an external DB instance, you can connect to the same database and perform blue / green deployments from multiple environments. For detailed instructions, see Using Elastic Beanstalk with Amazon RDS.

Add a DB Instance to Your Environment

How to add a DB instance to your environment

  1. Open the Elastic Beanstalk console and select from the list Regions Your AWS Region.

  2. Select in the navigation area Environments then select the name of your environment from the list.

    If you have many environments, use the search bar to filter the list of environments.

  3. Select in the navigation area Configuration out.

  4. Select in the configuration category Database the option Edit.

  5. Select a DB engine and enter your username and password.

  6. Choose Apply out.

Adding a DB instance takes about 10 minutes. Once the environment update is complete, the host name of the DB instance and other connection information are available through the following environment properties:

Property namedescriptionProperty value

The host name of the DB instance.

On the tab Connectivity & security (connectivity and security) in the Amazon RDS console: Endpoint.

The port on which the DB instance accepts connections. The DB engines have different default values.

On the tab Connectivity & security (connectivity and security) on the Amazon RDS console: port.

The database name,

On the tab Configuration the Amazon RDS console: DB name.

The username that was configured for the database.

On the tab Configuration in the Amazon RDS console: Master username.

The password that was configured for the database.

Not available for reference in the Amazon RDS console.

For more information on configuring an internal DB instance, see Adding a Database to Your Elastic Beanstalk Environment.

Download a driver

To use PHP Data Objects (PDO) to connect to the database, install the driver for the database engine you have chosen.

More information is available at

Connect to a database with a PDO or MySQLi

You can use to read the connection information in the area.

Create a Data Source Name (DSN) for a PDO from the host, port and name. Pass the DSN on to the constructor for the PDO with the username and password of the database.

Example connecting to an RDS database with PDO - MySQL

For other drivers, replace -, or with the name of your driver.

For MySQLi, pass the host name, username, password, database name and port to the constructor.

Example connecting to an RDS database with mysqli_connect ()

Connect to a database with symfony

For Symfony 3.2 or later, you can set database parameters in a configuration file based on the Elastic Beanstalk environment properties.

Example app / config / parameters.yml

See External Parameters (Symfony 3.4) for more information.

In previous versions of Symfony, environment variables could only be accessed if the name began with. This means that the Elastic Beanstalk-defined environment properties are not accessible and you have to define your own environment properties in order to transmit the connection data to Symfony.

To connect a database to Symfony 2, you create an environment property for each parameter. You then use to access the variable converted for symfony in a configuration file. Example: An environment property named can be accessed as.

See External Parameters (Symfony 2.8) for more information.