env/dotenv

A simple, tiny and lightweight PHP .env loader

v2.0.0 2023-08-21 09:43 UTC

This package is auto-updated.

Last update: 2024-12-21 12:51:20 UTC


README

A simple and tiny PHP .env loader, which does not inject values into $_ENV or OS.

Installation

composer require env/dotenv

Usage

The .env file should have a valid .ini syntaxis, supported by parse_ini_file.

This package does not inject values into global $_ENV or OS wia putenv() so it's up to you how you wan't proceed with parsed data.

Load

Parse .env and get values as array:

$env = \Env\Dotenv::toArray(
    path: '.env',
    strict: false, // by default: true
);

If you need variables and fallback values, set strict to false