App Platform is a Platform-as-a-Service (PaaS) offering that allows developers to publish code directly to DigitalOcean servers without worrying about the underlying infrastructure.
The PHP buildpack applies to this sample app. See the PHP buildpack overview for more information about its configuration options and limitations.
This page is automatically generated from https://github.com/digitalocean/sample-php/blob/main/README.md.
We provide a sample app using PHP that you can deploy on App Platform. These steps will get this sample application running for you using App Platform.
Note: Following these steps may result in charges for the use of DigitalOcean services.
Click this button to deploy the app to the DigitalOcean App Platform. If you are not logged in, you will be prompted to log in with your DigitalOcean account.
Using this button disables the ability to automatically re-deploy your app when pushing to a branch or tag in your repository as you are using this repo directly.
If you want to automatically re-deploy your app, fork the GitHub repository to your account so that you have a copy of it stored to the cloud. Click the Fork button in the GitHub repository and follow the on-screen instructions.
After forking the repo, you should now be viewing this README in your own GitHub org (e.g. https://github.com/<your-org>/sample-php
). To deploy the new repo, visit https://cloud.digitalocean.com/apps and click Create App. Then, click GitHub, select the repository you created and select the main
branch. App Platform will inspect the code, automatically detect the kind of component to create, and use the correct buildpack to create and deploy a container.
After clicking the Deploy to DigitalOcean button or completing the instructions above to fork the repo, follow these steps:
If you followed the steps to fork the repo and used your own copy when deploying the app, you can push changes to your fork and see App Platform automatically re-deploy the update to your app. During these automatic deployments, your application will never pause or stop serving request because App Platform offers zero-downtime deployments.
Here’s an example code change you can make for this app:
index.php
and change the default message, “Set a message by adding ?message=main
branch. Normally it’s a better practice to create a new branch for your change and then merge that branch to main
after review, but for this demo you can commit to the main
branch directly.You can learn more about the App Platform and how to manage and update your application at https://www.digitalocean.com/docs/app-platform/.
When you no longer need this sample application running live, you can delete it by following these steps:
Note: If you do not delete your app, charges for using DigitalOcean services will continue to accrue.
php
dependency to composer.json
like so:{
"require": {
"php": "^8.0.0"
}
}
We recommend using Composer for PHP apps that are deployed to App Platform. If your app does not use Composer, you must include an index.php
file in the root directory of its repo.
Composer versions 1.x and 2.x are supported. App Platform will determine the version to use based on the version of Composer that generated the composer.lock
file. Generally, you can update your project by running composer update --lock
using Composer 2.