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

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

sobyte/dotenv-php
=================

A optimize for vlucas/phpdotenv in PHP fastcgi application

v2.0.0(7y ago)190MITPHPPHP &gt;=7.0

Since Nov 16Pushed 7y agoCompare

[ Source](https://github.com/mingo6/dotenv-php)[ Packagist](https://packagist.org/packages/sobyte/dotenv-php)[ RSS](/packages/sobyte-dotenv-php/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

==========

This is a optimize for `vlucas/phpdotenv` in PHP fastcgi application.

`vlucas/phpdotenv` is excellent. However we found it takes a lot time to read and parse `.env` file in fastcgi. Thus this library comes out to use native PHP file as environment configuration file.

Advantages:

1. `.env.php` can be cached by opcache. It takes much less time than `.env`.
2. Any PHP code can be in `.env.php`. You can do more things (i.e. include files, calculate something, concatenating strings...).

Disadvantages:

1. `.env.php` cannot be loaded by other languages like JavaScript, Java, Ruby... But who cares. :)

Install
=======

[](#install)

Composer is suggested to use:

```
composer require sobyte/dotenv-php

```

You can also download the zip file and write your own autoloader.

.env.php
========

[](#envphp)

You can use everything of PHP in `.env.php`. But it is suggested to do as less as possible. An array must be returned:

```
// A simple .env.php

return [
    "APP_ENV" => "local",
    "APP_DEBUG" => true,
    // ....
];
```

It is advised that:

1. Do **NOT** add `.env.php` file to your version system (i.e. git/svn).
2. `.env.php` should only store configurations which diffs and which are secrets.

Usage
=====

[](#usage)

It is very similar with `vlucas/phpdotenv`. After you have created a `.env.php` file, you can use the following code to load it:

```
// assume .env.php is in current directory (__DIR__)
(new \Sobyte\DotEnv\DotEnv(__DIR__))->load();
```

You can use `env($key)` function to get the value:

```

echo env('APP_ENV'); // => local

```

All environment variables are also stored in `$_ENV`, `$_SERVER`. You can also use these super globals.

Note: the default behavior of `->load()` is not to override existing environment variables. If you wanna override, please use `->load(true)` or `->overload()`.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.7% 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 ~749 days

Total

2

Last Release

2717d ago

Major Versions

v1.0.3 → v2.0.02018-12-06

PHP version history (2 changes)v1.0.3PHP &gt;=5.4

v2.0.0PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/436ea1d0beda7273f6be426e03b4520fb15a9212133a7447f808d2e7d385d338?d=identicon)[Robyte](/maintainers/Robyte)

---

Top Contributors

[![Clarence-pan](https://avatars.githubusercontent.com/u/8750132?v=4)](https://github.com/Clarence-pan "Clarence-pan (6 commits)")[![mingo6](https://avatars.githubusercontent.com/u/24412465?v=4)](https://github.com/mingo6 "mingo6 (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[webdevstudios/oops-wp

A collection of interfaces and class structures to promote object-oriented programming practices in WordPress.

5820.7k1](/packages/webdevstudios-oops-wp)

PHPackages © 2026

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