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.0.0(5y ago)0598↓50%[1 PRs](https://github.com/tflori/envparser/pulls)1MITPHPPHP ^7.1

Since Aug 27Pushed 1y ago1 watchersCompare

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

READMEChangelog (5)Dependencies (3)Versions (8)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)[![Test Coverage](https://camo.githubusercontent.com/00f4d39f5f10e7d53c08a42809cfa62b7180e9eb98c34cc8741d89efd7594ee0/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f37663161306534333862316639393831616135392f746573745f636f766572616765)](https://codeclimate.com/github/tflori/envparser/test_coverage)[![Maintainability](https://camo.githubusercontent.com/00ef55005daa7945bb53d581dc7ff796d391c796d1c4661067db66609e42d9a7/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f39343334626136343936333463623537376238372f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/tflori/envparser/maintainability)[![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

29

—

LowBetter than 59% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

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

Total

5

Last Release

1504d ago

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

v1.0.0-rc.4PHP ^7.1 || ^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 (36 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### 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

[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k89.3M627](/packages/jms-serializer-bundle)[hassankhan/config

Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files

97513.5M170](/packages/hassankhan-config)[meyfa/php-svg

Read, edit, write, and render SVG files with PHP

54613.9M42](/packages/meyfa-php-svg)

PHPackages © 2026

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