PHPackages                             zablose/dotenv - 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. zablose/dotenv

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

zablose/dotenv
==============

Read '.env' file or files to a static array.

2.0.0(1y ago)087↓100%1MITPHPPHP ^8.3CI passing

Since Dec 6Pushed 1y ago1 watchersCompare

[ Source](https://github.com/zablose/dotenv)[ Packagist](https://packagist.org/packages/zablose/dotenv)[ RSS](/packages/zablose-dotenv/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (2)Versions (10)Used By (1)

[![](https://github.com/zablose/dotenv/actions/workflows/tests-on-master.yml/badge.svg)](https://github.com/zablose/dotenv/actions/workflows/tests-on-master.yml/badge.svg)[![](https://github.com/zablose/dotenv/actions/workflows/tests-on-dev.yml/badge.svg)](https://github.com/zablose/dotenv/actions/workflows/tests-on-dev.yml/badge.svg)

DotEnv
======

[](#dotenv)

Read '.env' file or files to a static array.

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

[](#installation)

```
composer require zablose/dotenv

```

Usage
-----

[](#usage)

### Read '.env' file(s)

[](#read-env-files)

Probably in your `index.php` after autoloader.

```
use Zablose\DotEnv\Env;

// Autoloader

(new Env())->setArrays(['PROTECTED'])
    ->read(__DIR__.'/../.env')
    ->read(__DIR__.'/../.env-extra');
```

### Get ENV

[](#get-env)

```
use Zablose\DotEnv\Env;

$db_name = Env::string('DB_NAME', 'dotenv');
$db_password = Env::string('DB_PASSWORD');
$db_port = Env::int('DB_PORT');
```

Or

> Works, if helper function is in use - added to the project's composer `autoload -> files` section.

```
$db_name = env_string('DB_NAME', 'dotenv');
$db_password = env_string('DB_PASSWORD');
$db_port = env_int('DB_PORT');
```

What is supported?
------------------

[](#what-is-supported)

> Look at [ENVs](./tests/data/envs) testing examples for more info.

### Variables

[](#variables)

```
USER=username
EMAIL=${USER}@domain.com

```

### Arrays

[](#arrays)

```
PROTECTED_0=_token
PROTECTED_1=password

```

### Value Types

[](#value-types)

TypeExampleBooleanDEBUG\_ON=trueFloatPI=3.14IntegerRAM=128StringGREETING=Welcome back!Development
-----------

[](#development)

> Check submodule's [readme](https://github.com/zablose/docker-images/blob/main/readme.md) for more details about development environment used.

### Quick start

[](#quick-start)

```
$ git clone -b 'dev' --single-branch --depth 1 https://github.com/zablose/dotenv.git dotenv
$ cd dotenv
$ git submodule update --init

# Copy env file, then ammend it to your needs.
$ cp .env.example .env

# Copy docker compose file, then ammend it, if needed.
$ cp docker-compose.example.yml docker-compose.yml

$ docker-compose up -d

# To see post-script logs, while container is starting.
$ tail -f ./logs/all.log

# To enter container, using Bash shell.
$ docker exec -it dotenv-php-fpm bash

(dotenv-php-fpm)$ php vendor/bin/phpunit

```

### Build

[](#build)

- Merge changes from your branch to `master`;
- Create a new branch from updated `master` called like `build-2.0.0`;
- Run `php vendor/bin/phing prepare` to remove all irrelevant files and folders;
- Commit changes with message like `Prepare build.`;
- Merge branch `build-2.0.0` to `build` branch;
- Delete `build-*` branch;
- Use tag `2.0.0` on `build` branch to do the release.

> Obviously, replace example `2.0.0` version with yours.

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance46

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity74

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 ~264 days

Recently: every ~372 days

Total

7

Last Release

403d ago

Major Versions

1.2.3 → 2.0.02025-04-09

PHP version history (3 changes)1.0.0PHP ^7.4

1.1.0PHP ^7.4|^8.0

2.0.0PHP ^8.3

### Community

Maintainers

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

---

Top Contributors

[![zablose](https://avatars.githubusercontent.com/u/8734335?v=4)](https://github.com/zablose "zablose (56 commits)")

---

Tags

envphpdotenv

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/zablose-dotenv/health.svg)

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

###  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)[josegonzalez/dotenv

dotenv file parsing for PHP

2799.8M137](/packages/josegonzalez-dotenv)[helhum/dotenv-connector

Makes it possible to set environment variables for composer projects.

1594.6M34](/packages/helhum-dotenv-connector)[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)[jackiedo/dotenv-editor

The .env file editor tool for Laravel 5.8+

2041.2M31](/packages/jackiedo-dotenv-editor)

PHPackages © 2026

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