Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Heya @darshanhiranandani,
I’ll recommend you to check the following docs :
https://docs.digitalocean.com/products/app-platform/how-to/use-environment-variables/
It’s exactly what you are looking for
Hi Darshan,
Deploying a PHP application on DigitalOcean’s App Platform and configuring environment variables is straightforward!
Define Variables in App Platform:
Use Environment Variables in PHP:
getenv() or $_ENV.$dbHost = getenv('DB_HOST');
$dbUser = getenv('DB_USER');
$dbPass = getenv('DB_PASS');
Feel free to share more information about your PHP app setup and I can give you more details on this!
Some things that you should always consider are:
Sensitive Data Handling:
Use a .env File Locally:
.env file to store environment variables.vlucas/phpdotenv to load variables from the .env file into your PHP environment.require 'vendor/autoload.php';
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
$dotenv->load();
Version Control Exclusions:
.env file is included in your .gitignore file to prevent it from being committed to version control.# .gitignore
.env
For more detailed instructions, you can refer to the official DigitalOcean documentation.
Hope this helps, and happy deploying!
- Bobby