PHPackages                             jasny/application-env - 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. jasny/application-env

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

jasny/application-env
=====================

Logic around the APPLICATION\_ENV environment variable

v1.0.2(1y ago)0671↓85.7%MITPHPPHP &gt;=8.1.0CI failing

Since Aug 9Pushed 1y agoCompare

[ Source](https://github.com/jasny/application-env)[ Packagist](https://packagist.org/packages/jasny/application-env)[ RSS](/packages/jasny-application-env/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (3)Versions (4)Used By (0)

[![jasny-banner](https://user-images.githubusercontent.com/100821/62123924-4c501c80-b2c9-11e9-9677-2ebc21d9b713.png)](https://user-images.githubusercontent.com/100821/62123924-4c501c80-b2c9-11e9-9677-2ebc21d9b713.png)

ApplicationEnv
==============

[](#applicationenv)

[![Build Status](https://github.com/jasny/application-env/actions/workflows/php.yml/badge.svg)](https://github.com/jasny/application-env/actions/workflows/php.yml)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/0f20a171d22893ab3adc6326214829c1c0ae39b5d2dd3f3411605555a00f23b4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a61736e792f6170706c69636174696f6e2d656e762f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jasny/application-env/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/210d96e39becc062535f68af9634fef6f248571f24c6d86fe58b4741f798c959/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a61736e792f6170706c69636174696f6e2d656e762f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jasny/application-env/?branch=master)[![Packagist Stable Version](https://camo.githubusercontent.com/3f87ecdaa0081065386b530c871a5b2e59e3b1b1059d34e5c811c6a329fda06f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a61736e792f6170706c69636174696f6e2d656e762e737667)](https://packagist.org/packages/jasny/application-env)[![Packagist License](https://camo.githubusercontent.com/721953f2c50f9c3cb52cb3b3502b4fff9f3f7c7ecc079d5dd15b288f369fb4a5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a61736e792f6170706c69636174696f6e2d656e762e737667)](https://packagist.org/packages/jasny/application-env)

Logic around the common `APPLICATION_ENV` environment variable.

Check and process dot-separated sub-environments like `dev.testers.john`.

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

[](#installation)

```
composer require jasny/application-env

```

Usage
-----

[](#usage)

```
use Jasny\ApplictionEnv;

$env = new ApplicationEnv(getenv('APPLICATION_ENV') ?? 'dev');

echo "Application environment: ", (string)$env;
```

### Check environment

[](#check-environment)

The `is` method checks if the current application env matches the given one, or is a sub-environment of it.

```
if ($env->is("dev")) {
   ini_set('display_errors', true);
}
```

This would match `dev` and `dev.testers.john`, but not `staging` or `prod.worker`.

### Get levels

[](#get-levels)

```
array getLevels(int from = 1, ?int to = null, callable $callback = null)

```

The `getLevels` method returns an array with environment variable levels. Starting from level 1 starts with the first level, while starting from 0 will include an empty string.

The `to` parameter allows to limit how deep to traverse. By default the full application env is the last entry.

A `callback` may be specified, which is called on each level.

**Example**

If the `APPLICATION_ENV` is `dev.testers.john` than `getLevels()` would yield;

```
[
  'dev',
  'dev.testers',
  'dev.testers.john'
]

```

To create a list of configuration files to be considered, you might use

```
$configFiles = $env->getLevels(
  from: 0,
  callback: fn(string $env) => $env === '' ? "settings.{$env}.yml" : "settings.yml"
);
```

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity73

Established project with proven stability

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

Total

3

Last Release

622d ago

PHP version history (3 changes)v1.0.0PHP &gt;=7.1.0

v1.0.1PHP &gt;=7.2.0

v1.0.2PHP &gt;=8.1.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/3379a93d51305df325df9045e1a8b205d195e4e8c01312dff53a000ee79002eb?d=identicon)[jasny](/maintainers/jasny)

---

Top Contributors

[![jasny](https://avatars.githubusercontent.com/u/100821?v=4)](https://github.com/jasny "jasny (11 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/jasny-application-env/health.svg)

```
[![Health](https://phpackages.com/badges/jasny-application-env/health.svg)](https://phpackages.com/packages/jasny-application-env)
```

###  Alternatives

[symfony/remote-event

Eases handling remote events

293.0M6](/packages/symfony-remote-event)[stephenjude/filament-blog

Filament Blog Builder

20317.8k](/packages/stephenjude-filament-blog)

PHPackages © 2026

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