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

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

yiithings/yii2-dotenv
=====================

PHP DotEnv for Yii2 framework

1.1.0(3y ago)40574.5k↓12.9%16[4 issues](https://github.com/panlatent/yii2-dotenv/issues)[1 PRs](https://github.com/panlatent/yii2-dotenv/pulls)7MITPHPPHP &gt;=8.0

Since Jan 22Pushed 3y ago2 watchersCompare

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

READMEChangelogDependencies (3)Versions (5)Used By (7)

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

[](#yii2-dotenv)

[![Build Status](https://github.com/panlatent/yii2-dotenv/actions/workflows/tests.yml/badge.svg)](https://github.com/panlatent/yii2-dotenv/actions/workflows/tests.yml)[![Latest Stable Version](https://camo.githubusercontent.com/0d62886ffc51dd1a49f36bb546f080efc126c81b83764607454bbd35aefc3230/68747470733a2f2f706f7365722e707567782e6f72672f7969697468696e67732f796969322d646f74656e762f762f737461626c652e737667)](https://packagist.org/packages/yiithings/yii2-dotenv)[![Total Downloads](https://camo.githubusercontent.com/371deadeaf631473a9c5f1df89ea5dd8fb92acba31877491494439871d27b0e6/68747470733a2f2f706f7365722e707567782e6f72672f7969697468696e67732f796969322d646f74656e762f646f776e6c6f6164732e737667)](https://packagist.org/packages/yiithings/yii2-dotenv)[![Latest Unstable Version](https://camo.githubusercontent.com/5ef9f8d0e8b6e59eb938a36a459dd74e89eed431b55c3dfd277322665363beb0/68747470733a2f2f706f7365722e707567782e6f72672f7969697468696e67732f796969322d646f74656e762f762f756e737461626c652e737667)](https://packagist.org/packages/yiithings/yii2-dotenv)[![License](https://camo.githubusercontent.com/4725383c8d32386c355e21ff857a5f364b73920d79ad97bb8b14b8a364b644a4/68747470733a2f2f706f7365722e707567782e6f72672f7969697468696e67732f796969322d646f74656e762f6c6963656e73652e737667)](https://packagist.org/packages/yiithings/yii2-dotenv)

PHP DotEnv for Yii2 framework.

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

[](#installation)

Then tell [Composer](https://getcomposer.org) to load the extension:

```
composer require yiithings/yii2-dotenv
```

Configuration
-------------

[](#configuration)

The extension default load environment variables from `.env` file in your application root directory. You can change the file path and name configure in your application entry file:

```
define('DOTENV_PATH', '/path/to/.env');
define('DOTENV_FILE', '.env');
define('DOTENV_OVERLOAD', false);
```

Usage
-----

[](#usage)

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

```
[
    'db' => [
        'username' => env('DB_USERNAME', 'root'),
        '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 no 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

44

—

FairBetter than 92% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity50

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 86.4% 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 ~574 days

Total

4

Last Release

1315d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.5.0

1.1.0PHP &gt;=8.0

### Community

Maintainers

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

---

Top Contributors

[![panlatent](https://avatars.githubusercontent.com/u/4393268?v=4)](https://github.com/panlatent "panlatent (19 commits)")[![Webkadabra](https://avatars.githubusercontent.com/u/1168612?v=4)](https://github.com/Webkadabra "Webkadabra (3 commits)")

---

Tags

php-dotenvyii2-frameworkdotenvyii2extension

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[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)
