In the PHP world, this usually mean a .env file in the root of your project. Most modern frameworks, such as Laravel and Symfony, come with built in support for a .env file.

In some cases, you might simply prefer to use a more standard environment file over the way in which configuration is currently provided by your project.

If not, make sure you include vendor/autoload.php in any file you wish to access your .env file variables from. You can now create a .env file in the root of your project, alongside your composer.json file and populate it as follows.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners