horat1us/yii2-current-environment

Yii2 Current Environment Provider

1.0.0-RC2 2021-02-22 04:29 UTC

This package is auto-updated.

Last update: 2024-12-22 13:20:48 UTC


README

codecov

Русская версия Library provides class to get current environment (YII_ENV) of Yii2 application.

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 is used for configuring Yii2 applications environment. It makes testing environment-depending code difficult because constant redefining is impossible without external extensions.

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

Using composer

composer install horat1us/yii2-current-environment

Setup

For usage inside libraries

Use CurrentEnvironment\Facade as dependency for your services in pair with DI Container.

Example

For usage inside application

To set up CurrentEnvironment\Facade singleton inside Yii2 DI Container, both with 'env' application component use CurrentEnvironment\Bootstrap inside your application configuration.

Example

Authors