PHPackages                             horat1us/yii2-current-environment - 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. horat1us/yii2-current-environment

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

horat1us/yii2-current-environment
=================================

Yii2 Current Environment Provider

1.0.0-RC2(5y ago)0469MITPHPPHP ^7.4 | 8.\*

Since Dec 12Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Horat1us/yii2-current-environment)[ Packagist](https://packagist.org/packages/horat1us/yii2-current-environment)[ RSS](/packages/horat1us-yii2-current-environment/feed)WikiDiscussions master Synced yesterday

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

Yii2 Current Environment
========================

[](#yii2-current-environment)

[![codecov](https://camo.githubusercontent.com/9d3af35991612ae036c86ac4caaf0aab9140f3cd104b20ae03a339d5ed4cc38a/68747470733a2f2f636f6465636f762e696f2f67682f486f7261743175732f796969322d63757272656e742d656e7669726f6e6d656e742f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d5359574d4d5545595454)](https://codecov.io/gh/Horat1us/yii2-current-environment)

[Русская версия](./README-RU.md)Library provides class to get current environment (YII\_ENV) of Yii2 application.

Purpose
-------

[](#purpose)

Main purpose is to make support, adaptation and modification of applications written using legacy Yii2 framework more friendly to modern programming trends.

[PHP constants](https://www.php.net/manual/en/language.constants.php) is used for [configuring Yii2 applications environment](https://github.com/yiisoft/yii2/blob/2.0.39.3/docs/guide/concept-configurations.md#environment-constants-). It makes testing environment-depending code difficult because constant redefining is impossible without [external extensions](https://www.php.net/manual/en/function.runkit7-constant-redefine.php).

This library provides simple solution for legacy application written using Yii2 as facade class that deals with Yii2 legacy (constant defining in libraries, global variables and static class storage).

Install
-------

[](#install)

Using [composer](https://getcomposer.org/)

```
composer install horat1us/yii2-current-environment
```

Setup
-----

[](#setup)

### For usage inside libraries

[](#for-usage-inside-libraries)

Use [CurrentEnvironment\\Facade](src/Facade.php)as dependency for your services in pair with [DI Container](https://github.com/yiisoft/yii2/blob/2.0.39.3/docs/guide-ru/concept-di-container.md).

[Example](./examples/01-example-library.php)

### For usage inside application

[](#for-usage-inside-application)

To set up [CurrentEnvironment\\Facade](src/Facade.php) singleton inside Yii2 [DI Container](https://github.com/yiisoft/yii2/blob/master/docs/guide-ru/concept-di-container.md), both with 'env' application component use [CurrentEnvironment\\Bootstrap](./src/Bootstrap.php)inside your application configuration.

[Example](./examples/02-example-application.php)

Authors
-------

[](#authors)

- [Alexander Letnikow](mailto:reclamme@gmail.com)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

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

Total

2

Last Release

1906d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2751367?v=4)[Horat1us](/maintainers/Horat1us)[@Horat1us](https://github.com/Horat1us)

---

Top Contributors

[![Horat1us](https://avatars.githubusercontent.com/u/2751367?v=4)](https://github.com/Horat1us "Horat1us (2 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/horat1us-yii2-current-environment/health.svg)

```
[![Health](https://phpackages.com/badges/horat1us-yii2-current-environment/health.svg)](https://phpackages.com/packages/horat1us-yii2-current-environment)
```

###  Alternatives

[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)

PHPackages © 2026

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