Before You Begin
This 10-minute tutorial you how to deploy a PHP application to Oracle Application Container Cloud Service and how to integrate Oracle MySQL Service with your application.
Background
Oracle Application Container Cloud Service provides a lightweight infrastructure so that you can run Java, PHP, and Node.js applications in Oracle Cloud. To develop more robust applications, you can integrate this cloud service with other Oracle services (for example, Oracle MySQL Cloud Service).
- An Oracle Cloud account
- Completion of Creating an Instance of Oracle MySQL Cloud Service
- cURL 7.0+ with Secure Sockets Layer (SSL) support
- PHP Employee application service employee-service.zip
Deploy Your Application to Oracle Application Container Cloud Service
- Log in to Oracle Cloud at http://cloud.oracle.com/. Enter your account credentials in the Identity Domain, User Name, and Password fields.
- To open
the Oracle Application Container Cloud Service console, click Instances in the dashboard.
Description of the illustration open_console.png - In the Applications list view, click Create Application.
- In the Create Application dialog box, click PHP.
- In the Application section, enter
EmployeeService
for the name of your application and click Browse. - In the File Upload dialog box, select the
employee-service.zip
file located in thetarget
directory, and click Open. - Keep the default values in the Instances and Memory fields and click Create.
Add the MySQLCS Service Binding
- Wait until the application is created and click the application name.
- Click the Deployments tab. In the Service Binding section, click Add.
- In the Service Type field, select MySQLCS Service. Enter or select values in the Service Name, Username, and Password fields, and click Save.
- In the Deployments dialog box, click Apply Edits.
- Wait until the application is restarted.
Test the Application
- In the Oracle Application Container Cloud Service console, click the URL of your application.
- Click Setup the database.
Description of the illustration index-page.png The
EMPLOYEE
table is created in the database, and it has five employee records.Description of the illustration setup_database.png - Open a command-line window (or terminal in Linux).
- Query all employee entities.
curl app_endpoint/employees-rest-api.php/employees
- Create an employee record and replace the
app_endpoint
placeholder with the URL of your application.curl -i -X POST -H "Content-Type:application/json" -d "{ \"firstName\" : \"John\", \"lastName\" : \"Smith\",\"birthDate\":\"1957-10-14\", \"phone\":\"193-754-4112\",\"email\":\"john.smith@example.com\",\"title\" : \"Manager\",\"dept\" : \"Sales\" }" app_endpoint/employees-rest-api.php/employees
Because five records were already inserted in the table, the ID of the new record is 6.
- Get the employee by ID.
curl app_endpoint/employees-rest-api.php/employees/6
- Update the employee.
curl -i -X PUT -H "Content-Type:application/json" -d "{ \"firstName\" : \"John\", \"lastName\" : \"Smith\",\"birthDate\":\"1957-12-08\", \"phone\":\"193-124-8212\",\"email\":\"john.smith@example.com\",\"title\" : \"Manager\",\"dept\" : \"IT\" }" app_endpoint/employees-rest-api.php/employees/6
- Delete the employee.
curl -i -X DELETE app_endpoint/employees-rest-api.php/employees/6
Want to Learn More?
- Oracle Application Container Cloud Service in the Oracle Help Center
- Deploy a PHP Application to Oracle Cloud tutorial
- Deploy an Application from GitHub by Using the Command-Line Interface tutorial