adistoe/env-loader

A loader for environment variables

1.1.0 2022-03-04 15:37 UTC

This package is auto-updated.

Last update: 2024-05-04 20:26:10 UTC


README

A PHP class to load environment variables from .env files

Installation

Install it using composer:

composer require adistoe/env-loader

Getting Started

Create a .env file or copy the .env.example (rename it to .env) and modify it as needed.
Then you can load the file with the following code:

EnvLoader::load('path/to/your/project/');

If no .env file exists in the given path, the EnvLoader will automatically search for a .env file in all subdirectories.

If the file is loaded correctly you can access your environment variables with over the php function:

getenv('NAME_OF_THE_VARIABLE');