Environment variables are configuration settings that you store outside your source code, such as database passwords, API keys and server addresses. They act as a separate file or system setting where you place sensitive data or environment-dependent values. This allows the same code to run on different environments (development, test, production) without having to modify code each time. For an SMB with an ecommerce store or custom application, this prevents passwords from ending up in your GitHub repository or a developer from accidentally overwriting production data during a test.
How environmental variables work in practice
You define environment variables in a separate configuration file (often called .env) or directly in your hosting environment. Your application reads these variables at startup. Suppose you have an ecommerce store that connects to Mollie for payments. Instead of putting your Mollie API key hard-coded into your PHP or JavaScript file, you put it into an environment variable such as MOLLIE_API_KEY. Your code retrieves that value with a function like getenv() or process.env. Switching from test key to live key? Then you only modify the value in your .env file, not your entire codebase. That saves errors and makes deployment to new servers much faster.
Why environmental variables arose and why they are essential today
In the past, developers often placed configuration directly in the code. That became a problem as teams got bigger and code was shared through platforms like GitHub. Passwords and keys became publicly available online, resulting in data breaches and security incidents. The Twelve-Factor App methodology made environment variables standard. Today, hosting platforms like Kinsta, Cloudways and Vercel require you to configure sensitive data via environment variables. It also makes sense for AVG compliance: you separate configuration from code, making audits easier and reducing your risk of inadvertent disclosure of personal data.
What environmental variables bring to web projects
For an SME with a WordPress site, ecommerce store or custom application, environment variables offer three concrete benefits. First, you increase security: API keys and passwords are not in your code repository. Second, you make deployment more flexible: the same codebase runs on local development environment, staging server and production, each with its own database credentials. Third, you simplify collaboration: a new developer clicks his own .env file and can get started right away without production access. With web development by Monkey Vision, we set up default environment variables for all custom projects, so your application remains scalable and secure as your team or infrastructure grows.