PHPackages                             opxcore/config-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. opxcore/config-environment

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

opxcore/config-environment
==========================

The OpxCore config environment loader.

1.0.6(5y ago)1108MITPHPPHP ^7.4

Since Jan 23Pushed 5y agoCompare

[ Source](https://github.com/opxcore/config-environment)[ Packagist](https://packagist.org/packages/opxcore/config-environment)[ Docs](https://opxcore.com)[ RSS](/packages/opxcore-config-environment/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (9)Dependencies (2)Versions (10)Used By (0)

Config environment loader
=========================

[](#config-environment-loader)

[![Build Status](https://camo.githubusercontent.com/5cfcd3dd32bae13ed3b0cfb3ad8df554634c8a652a6bba3adfb6399c1c051227/68747470733a2f2f7472617669732d63692e636f6d2f6f7078636f72652f636f6e6669672d656e7669726f6e6d656e742e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/opxcore/config-environment)[![Coverage Status](https://camo.githubusercontent.com/f85fa70e66bc40b0058b7b2549548c11b3278f9febba4ccd2d888478206f158e/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6f7078636f72652f636f6e6669672d656e7669726f6e6d656e742f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/opxcore/config-environment?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/bc5886cb65c84ae7ce54d09c55ee5c1ed9651d09dbacfdbbe28423d2da3d09af/68747470733a2f2f706f7365722e707567782e6f72672f6f7078636f72652f636f6e6669672d656e7669726f6e6d656e742f762f737461626c65)](https://packagist.org/packages/opxcore/config-environment)[![Total Downloads](https://camo.githubusercontent.com/433f03c9a68957a86558a020fa6d6c0c7132b2afba73f753733e504fadb3631d/68747470733a2f2f706f7365722e707567782e6f72672f6f7078636f72652f636f6e6669672d656e7669726f6e6d656e742f646f776e6c6f616473)](https://packagist.org/packages/opxcore/config-environment)[![License](https://camo.githubusercontent.com/ef9e462b89a166e1cf83689961410458988f0db29650b459918c1c60d41f33ba/68747470733a2f2f706f7365722e707567782e6f72672f6f7078636f72652f636f6e6669672d656e7669726f6e6d656e742f6c6963656e7365)](https://packagist.org/packages/opxcore/config-environment)

Installing
----------

[](#installing)

```
composer require opxcore/config-environment

```

Important notice
----------------

[](#important-notice)

All environment variables are stored in static property so any instance of environment would have access to the same set of environment variables.

Usage
-----

[](#usage)

```
use OpxCore\Config\Environment;

$environment = new Environment($path);
```

where `$path` is directory where environment file is placed.

### Loading environment

[](#loading-environment)

To load environment variables from file call `$environment->load($filename)`, where `$filename` is a name of file. **All variables would be stored locally, not affecting any of $\_ENV, $\_SERVER and so on**.

Additional arguments is `load($filename, $safe, $silent)`. If `$safe` is set to `true` variables would not be overwritten if they are already present. If `$silent` is set to `true` no exceptions would be thrown. Function returns `true` if environment file wss processed successfully, `false` in case of any errors.

### Reading environment variables

[](#reading-environment-variables)

`$environment->get($key, $default)` returns environment variable if it set, otherwise returns value assigned to default or return value of callable passed to as default.

`$environment->has($key)` returns `true` is environment variable set, `false` otherwise.

### Manipulations

[](#manipulations)

`$environment->set($key, $value, $safe)` sets value to environment. If `$safe` is set to `true` variables would not be overwritten if they are already present. Passed values of string type it would be parsed (see below), others would be set as is.

`$environment->unset($key)` removes variable from environment.

Format
------

[](#format)

Each line of environment must contain one value, consisting of variable name and its value separated by `=` sign. Other words, part of line before `=` sign would be used as variable name, another part would be value of variable.

For example:

```
APP_NAME=My awesome application
```

Each value would be parsed according next rules:

### String

[](#string)

Each quoted value would be converted to unquoted strings.

```
DB_CONNECTION="mysql"
DB_HOST="127.0.0.1"
```

Result of `$environment->get('DB_HOST')` would be `'127.0.0.1'`.

### Boolean

[](#boolean)

If value is `true` or `false` it would be converted to `boolean` type.

```
CACHE_ENABLE=true
304_RESPONSE=false
```

### Null

[](#null)

Null values would set to `null`

```
CACHE_DRIVER=null
```

### Array

[](#array)

Arrays must start with `[` and ends with `]`. Items must be separated by commas. Each item would be parsed according this rules. **Nested arrays are not supported**.

```
BROADCAST_DRIVER=[log,telegram]
```

### Numbers

[](#numbers)

If value represents any of number format it would be converted to integer or float.

```
COUNT=42
MULTIPLIER=1.05
FLOAT=0.15E-10
```

If parser would not recognise type of value, original string would be returned.

```
APP_KEY=base64:0vqkPYSbwPm3MOzdxQJ76Ps6pouZRjN5xPx3b+dm628=
```

Result of `$environment->get('APP_KEY')` would be `'base64:0vqkPYSbwPm3MOzdxQJ76Ps6pouZRjN5xPx3b+dm628='`.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 90.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 ~94 days

Recently: every ~12 days

Total

9

Last Release

1913d ago

Major Versions

0.1.1 → 1.0.02020-12-28

PHP version history (2 changes)0.1PHP ^7.1.3

1.0.0PHP ^7.4

### Community

Maintainers

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

---

Top Contributors

[![lozovoyv](https://avatars.githubusercontent.com/u/21274927?v=4)](https://github.com/lozovoyv "lozovoyv (19 commits)")[![opxcore](https://avatars.githubusercontent.com/u/46634185?v=4)](https://github.com/opxcore "opxcore (2 commits)")

---

Tags

opxcore

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/opxcore-config-environment/health.svg)

```
[![Health](https://phpackages.com/badges/opxcore-config-environment/health.svg)](https://phpackages.com/packages/opxcore-config-environment)
```

###  Alternatives

[pentiminax/ux-sweet-alert

SweetAlert2 integration for Symfony

254.4k](/packages/pentiminax-ux-sweet-alert)

PHPackages © 2026

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