Hi everyone! I’m Darshan Hiranandani, working on deploying a PHP application to App Platform and need some help with configuring environment variables. Can anyone share their experience or best practices for setting up environment variables in this environment? I’m looking for tips on how to manage and secure these variables effectively.
Regards Darshan Hiranandani
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!
Setting Up Environment Variables
Define Variables in App Platform:
Use Environment Variables in PHP:
getenv()
or$_ENV
.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.Version Control Exclusions:
.env
file is included in your.gitignore
file to prevent it from being committed to version control.For more detailed instructions, you can refer to the official DigitalOcean documentation.
Hope this helps, and happy deploying!
- Bobby