PHPackages                             tflori/envparser - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. tflori/envparser

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

tflori/envparser
================

v1.1.1(1mo ago)0704↓10.5%1MITPHPPHP ^7.4 || ^8.0CI passing

Since Aug 27Pushed 1mo ago1 watchersCompare

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

READMEChangelog (6)Dependencies (8)Versions (11)Used By (1)

tflori/envparser
================

[](#tflorienvparser)

[![.github/workflows/push.yml](https://github.com/tflori/envparser/actions/workflows/push.yml/badge.svg)](https://github.com/tflori/envparser/actions/workflows/push.yml)[![Code Coverage](https://camo.githubusercontent.com/93fb00ab578df882498bac47014d9ad99aff4b4870bd4dbb6cb3327a70777966/68747470733a2f2f716c74792e73682f67682f74666c6f72692f70726f6a656374732f656e767061727365722f636f7665726167652e737667)](https://qlty.sh/gh/tflori/projects/envparser)[![Maintainability](https://camo.githubusercontent.com/338d8c8bccdf01c823d158583d8580b08e1f18c79c7a494c3bad85b5ab21ac03/68747470733a2f2f716c74792e73682f67682f74666c6f72692f70726f6a656374732f656e767061727365722f6d61696e7461696e6162696c6974792e737667)](https://qlty.sh/gh/tflori/projects/envparser)[![Latest Stable Version](https://camo.githubusercontent.com/ea188ea2cafaecc73919106407b256d63a0f301aaf56d7204ee36ef1538456b2/68747470733a2f2f706f7365722e707567782e6f72672f74666c6f72692f656e767061727365722f762f737461626c652e737667)](https://packagist.org/packages/tflori/envparser)[![Total Downloads](https://camo.githubusercontent.com/52cd19de89f15f4c57fa8c25b7dbc1bac5954057926d2bba1ff1543d59a5d025/68747470733a2f2f706f7365722e707567782e6f72672f74666c6f72692f656e767061727365722f646f776e6c6f6164732e737667)](https://packagist.org/packages/tflori/envparser)[![License](https://camo.githubusercontent.com/5630d155ad351ddfe385375428aa7f26aef867b295fb297ba49f75325d9178f9/68747470733a2f2f706f7365722e707567782e6f72672f74666c6f72692f656e767061727365722f6c6963656e73652e737667)](https://packagist.org/packages/tflori/envparser)

A small library that is just reading an environment file in bash syntax and returns an array equal to that what you would get sourcing this file in a bash environment.

Features
--------

[](#features)

### Declarations of variables

[](#declarations-of-variables)

```
# a string without spaces
STRING1=foo

# a string with spaces surrounded by quotes
STRING2="foo's bar"
STRING3='"$quote" - $author'      # string '"$quote" - $author'
STRING4=foo"' "bar                # string 'foo\' bar'

# variable replacement (assuming user=thomas)
VAR1=$user                        # string 'thomas'
VAR2="$user's profile"            # string 'thomas\'s profile'
VAR3="${APP_ENV-production}"      # string 'production'

# array handling
ARRAY1=(foo bar)                  # array ['foo', 'bar']
ARRAY2=($int 6 7)                 # array [42, 6, 7]
ARRAY3=()                         # array []
ARRAY5[0]=foo                     # array ['foo']
ARRAY5[1]=bar                     # array ['foo', 'bar']
```

A lot of things available in bash are not possible in this library but the important ones will be. When you find something is missing please open a feature request on github or create a merge request.

### Using Environment

[](#using-environment)

All variables available in `$_ENV` and `getenv()` (or a passed array) are available inside the parsed file.

### Conversion of variables

[](#conversion-of-variables)

In bash every variable is a string like in \*nix every variable is a file and inside is a string. While it is very useful on this level we don't want that inside an application.

```
### null (case insensitive)
NULL1=                            # null (bash typical)
NULL2=null                        # null
NULL3="null"                      # null
STRING1='null'                    # string 'null'

### numbers (checked with is_numeric)
INT=42                            # int 42
INT2="23"                         # int 23
STRING2='42'                      # string '42'
FLOAT=23.2                        # float 23.2
FLOAT2="42.1"                     # float 42.1
STRING3='23.2'                    # string '23.2'

### true (case insensitive)
BOOL_TRUE=true                    # bool true
STRING4='true'                    # string 'true'

### ATTENTION! In php: ('false' != false)
BOOL_FALSE=false                  # bool false
STRING5='false'                   # string 'false'

### json (you should avoid json in environment files. it is just sugar; ext-json required)
OBJECT='json:{"foo":"bar"}'       # \stdobj ['foo' => 'bar']
ARRAY='jsonArray:{"foo":"bar"}'   # array ['foo' => 'bar']

### base64 (use it for unprintable characters)
APP_KEY="base64:dzN0ICJzZWNyZXQiCg=="
```

### Concatenation

[](#concatenation)

Strings are concatenated in bash by just connecting the strings together.

```
STRING1="hello"' $user'           # string 'hello $user'

### everything is a string when it gets concatenated
STRING2=True" Warrior"            # string 'True Warrior'
```

### Escaping

[](#escaping)

Escaping quotes works exactly the same as in bash:

```
STRING1="foo's \"bar\""
STRING2='foo'"'"'s "bar"'
STRING3='foo'\''s "bar"'
STRING4=$'foo\'s "bar"'
```

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance92

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 97.7% 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 ~357 days

Recently: every ~535 days

Total

7

Last Release

39d ago

PHP version history (3 changes)v1.0.0-rc.1PHP ^7.1

v1.0.0-rc.4PHP ^7.1 || ^8.0

v1.1.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4855611?v=4)[Thomas Flori](/maintainers/tflori)[@tflori](https://github.com/tflori)

---

Top Contributors

[![tflori](https://avatars.githubusercontent.com/u/4855611?v=4)](https://github.com/tflori "tflori (42 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tflori-envparser/health.svg)

```
[![Health](https://phpackages.com/badges/tflori-envparser/health.svg)](https://phpackages.com/packages/tflori-envparser)
```

###  Alternatives

[mwgg/airports

A JSON collection of ~29k entries with basic information about nearly every airport and landing strip in the world

7683.4k](/packages/mwgg-airports)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9845.4k](/packages/sauladam-shipment-tracker)[glauberportella/cnab-layouts-parser

Parser de arquivos de configuração CNAB gerados no projeto https://github.com/glauberportella/cnab-layouts

2154.5k](/packages/glauberportella-cnab-layouts-parser)[tcds-io/php-jackson

A lightweight, flexible object serializer for PHP, inspired by FasterXML/jackson

113.4k10](/packages/tcds-io-php-jackson)

PHPackages © 2026

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