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

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

masihfathi/yii2-dotenv
======================

PHP DotEnv for Yii2 framework

1.0.2(8y ago)04.0kMITPHPPHP &gt;=5.5.0

Since Jan 22Pushed 5y agoCompare

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

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

Yii2 DotEnv
===========

[](#yii2-dotenv)

PHP DotEnv for Yii2 framework.

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist masihfathi/yii2-dotenv "*"

```

or add

```
"masihfathi/yii2-dotenv": "*"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

Once the extension is installed, simply use it in your code by :

```
[
    'db' => [
        'password' => env('DB_PASS'),
    ],
]

```

The env function will autoload .env file, it uses the following search mechanism:

```
If there is a Yii class, then pass the alias @vendor or @app or @yii, Otherwise
according to the project directory to determine.

```

But, if your application vendor directory is a symbol link and you not registered @vendor or @app alias before call env function, the project will not working. So you should set the @vendor alias before calling env function.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 62.5% 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 ~35 days

Total

3

Last Release

2960d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/904bedb5b24b908c13b45a4c75ca1570f2e8bb56bf42ff58b3962c55637e156f?d=identicon)[masihfathi](/maintainers/masihfathi)

---

Top Contributors

[![panlatent](https://avatars.githubusercontent.com/u/4393268?v=4)](https://github.com/panlatent "panlatent (10 commits)")[![masihfathi](https://avatars.githubusercontent.com/u/13271510?v=4)](https://github.com/masihfathi "masihfathi (6 commits)")

---

Tags

dotenvyii2extension

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[yiithings/yii2-dotenv

PHP DotEnv for Yii2 framework

40574.5k7](/packages/yiithings-yii2-dotenv)[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)[richardfan1126/yii2-js-register

Yii2 widget to register JS into view

1357.2k7](/packages/richardfan1126-yii2-js-register)

PHPackages © 2026

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