adistoe/env-loader

A loader for environment variables

Installs: 483

Dependents: 1

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 1

Open Issues: 0

pkg:composer/adistoe/env-loader

1.1.0 2022-03-04 15:37 UTC

This package is auto-updated.

Last update: 2025-10-04 23:36:25 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');