PHPackages                             ocolin/easyenv - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ocolin/easyenv

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ocolin/easyenv
==============

Very simple tool to load env variables from file

v3.0.1(1mo ago)012720MITPHPPHP &gt;=8.3

Since Apr 26Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/ocolin/EasyEnv)[ Packagist](https://packagist.org/packages/ocolin/easyenv)[ RSS](/packages/ocolin-easyenv/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (6)Versions (11)Used By (20)

EasyEnv
=======

[](#easyenv)

What is it?
-----------

[](#what-is-it)

EasyEnv is a simple tool for loading environment variables into your PHP project. It is designed for minimal hassle, but with optional parameters for expanded control.

Why it exists
-------------

[](#why-it-exists)

There are plenty of tools out there for loading environment variables that are wonderful. I wanted to add one that was just as simple to use if not easier, but also with the ability to prevent the data from being inserted into specific global or environmental spaces.

Often times the data can be sensitive and existing in some environments may be a security issue for some users. It allows loading into `$_ENV` while not `$_SERVER` or system environment unless so desired.

Requirements
------------

[](#requirements)

This plugin was designed for PHP 8.2 or above.

Installation
------------

[](#installation)

```
composer require Ocolin\EasyEnv

```

Environment variables and the prefix
------------------------------------

[](#environment-variables-and-the-prefix)

What makes this tool useful is the prefix parameter. Rather than specifying each variable to create a database handler, you provide a prefix name. The prefix is the beginning of the environment variable names used for your database connection.

### Example:

[](#example)

Prefix of "MYDB"

This will load the following environment variables for your database handler:

Basic Usage
-----------

[](#basic-usage)

By default, the only thing you need is the path of your env file or an array of file paths if there are multiple env files to load.

### Single file

[](#single-file)

```
use Ocolin\EasyEnv\Env;

Env::load( '/path/to/.env' );
```

### Multiple files

[](#multiple-files)

Files are loaded in order, with later files taking priority over earlier ones on conflicting keys.

```
use Ocolin\EasyEnv\Env;

Env::load( files: [
    '/path/to/.env.local',
    '/path/for/.env',
    '/path/directory/' // Will look for '.env' file
]);
```

Optional Reference
------------------

[](#optional-reference)

Here are some of the optional arguments that can be used for finer control:

ArgumentTypeDescriptionDefaultfilesstring|arrayPath to file or array of filesN/aappendbooleanDoes not overwrite existing variablesfalsesilentbooleanDoes not throw errors loading filesfalsesystembooleanLoads into system environmenttrueserverbooleanLoads into $\_SERVER globalfalseAdvanced Usage
--------------

[](#advanced-usage)

### Options

[](#options)

```
use Ocolin\EasyEnv\Env;
Env::load(
    files: '/path/.env',
    append: true,
    silent: true,
    system: false,
    server: true
)
```

### Parse

[](#parse)

You can also parse a file into an array of values, which can be handy if you want to load them into something other than an environment.

```
use Ocolin\EasyEnv\Env;

$array = Env::parse( file: '/path/file' );
```

Contributing/License
--------------------

[](#contributinglicense)

MIT — free to use, modify, and distribute. See [LICENSE](LICENSE) for details.

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance89

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~87 days

Recently: every ~79 days

Total

9

Last Release

56d ago

Major Versions

1.2 → 2.0.02025-05-08

2.8 → v3.0.02026-03-20

PHP version history (2 changes)v3.0.0PHP &gt;=8.2

v3.0.1PHP &gt;=8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/e97ac0aa452b872ddc3f7f4c56c83852574a27bb74622f8c054d11ca20008fc9?d=identicon)[Ocolin](/maintainers/Ocolin)

---

Top Contributors

[![ocolin](https://avatars.githubusercontent.com/u/8870196?v=4)](https://github.com/ocolin "ocolin (3 commits)")

---

Tags

configenvironmentenvdotenv

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ocolin-easyenv/health.svg)

```
[![Health](https://phpackages.com/badges/ocolin-easyenv/health.svg)](https://phpackages.com/packages/ocolin-easyenv)
```

###  Alternatives

[vlucas/phpdotenv

Loads environment variables from `.env` to `getenv()`, `$\_ENV` and `$\_SERVER` automagically.

13.5k602.4M5.4k](/packages/vlucas-phpdotenv)[symfony/dotenv

Registers environment variables from a .env file

3.8k226.7M2.3k](/packages/symfony-dotenv)[m1/env

Env is a lightweight library bringing .env file parser compatibility to PHP. In short - it enables you to read .env files with PHP.

6412.0M21](/packages/m1-env)[cekurte/environment

A library to get the values from environment variables and process to php data types

5884.0k7](/packages/cekurte-environment)[diarmuidie/envpopulate

Tool to interactively populate a `.env` file based on an `.env.example` file whenever Composer installs or updates.

1892.0k](/packages/diarmuidie-envpopulate)[zepgram/magento-dotenv

Simple autoloader to integrate the Symfony Dotenv component into Magento2

1371.3k](/packages/zepgram-magento-dotenv)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
