Skip to content

Commit b7b9c3b

Browse files
committed
Update readme, fix tests
1 parent ca6a3fc commit b7b9c3b

File tree

3 files changed

+41
-10
lines changed

3 files changed

+41
-10
lines changed

README.md

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,31 @@
1313

1414
Env is a lightweight library bringing .env file parser compatibility to PHP. In short - it enables you to read .env files with PHP.
1515

16+
* [Why?](#why)
17+
* [Requirements](#requirements)
18+
* [Install](#install)
19+
* [Usage](#usage)
20+
* [Basic](#basic)
21+
* [Syntax](#syntax)
22+
* [Assignment](#assignment)
23+
* [Strings](#strings)
24+
* [Numbers](#numbers)
25+
* [Booleans](#booleans)
26+
* [Null](#null)
27+
* [Variables](#variables)
28+
* [Default Value/Assignment](#parameter-expansion)
29+
* [Comments](#comments)
30+
* [.env example)(#env-example)
31+
* [Other library comparisons](#other-library-comparisons)
32+
* [Todo](#todo)
33+
* [Change log](#change-log)
34+
* [Testing](#testing)
35+
* [Contributing](#Contributing)
36+
* [Security](#security)
37+
* [Credits](#credits)
38+
* [License](#license)
39+
40+
1641
## Why?
1742
Env aims to bring a unified parser for env together for PHP rather than having a few incomplete or buggy parsers written
1843
into other libraries. This library is not meant as a complete package for config loading like other libraries as this
@@ -203,6 +228,8 @@ TEST2 = ${TEST1} # `null` type
203228
TEST3 = "${TEST1}" # `string` type
204229
```
205230

231+
##### Parameter Expansion
232+
206233
You can do parameter expansion, so far you can only do [default values](http://wiki.bash-hackers.org/syntax/pe#use_a_default_value)
207234
and [assign default values](http://wiki.bash-hackers.org/syntax/pe#assign_a_default_value) like in the bash syntax:
208235

@@ -268,7 +295,7 @@ To comment, just use the `#` syntax, you can also comment inline like so:
268295
TEST1 = bar # and so is this
269296
```
270297

271-
### full .env example
298+
### .env example
272299

273300
```bash
274301
# Comments are done like this
@@ -360,9 +387,9 @@ TEST59=${TEST60:=null} # TEST59 = null TEST60 = null -- both `null` types
360387
TEST61=${TEST62:=true} # TEST61 = true TEST62 = true -- both `bool` types
361388
362389
# Comments
363-
TEST62 = hello # comment
364-
TEST63 = "hello # comment"
365-
TEST64 = "hello" #comment
390+
TEST63 = hello # comment
391+
TEST64 = "hello # comment"
392+
TEST65 = "hello" #comment
366393
TEST66 = #comment
367394
TEST67 = "#comment"
368395
```
@@ -441,6 +468,9 @@ array(
441468
## Other library comparisons
442469
todo
443470

471+
## Todo
472+
- Other library comparisons
473+
- [Other bash parameter expansions](http://wiki.bash-hackers.org/syntax/pe#display_error_if_null_or_unset)
444474
## Change log
445475

446476
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

tests/EnvTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,11 @@ public function testFinalCase()
249249
'TEST59' => null,
250250
'TEST62' => true,
251251
'TEST61' => true,
252-
'TEST63' => 'hello # comment',
253-
'TEST64' => 'hello',
252+
'TEST63' => 'hello',
253+
'TEST64' => 'hello # comment',
254+
'TEST65' => 'hello',
254255
'TEST66' => null,
255-
'TEST67' => '#comment',
256+
'TEST67' => '#comment'
256257
);
257258

258259
$env = Env::Parse(__DIR__.'/mocks/all_testcase.env');

tests/mocks/all_testcase.env

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ TEST59=${TEST60:=null}
8787
TEST61=${TEST62:=true}
8888

8989
# Comments
90-
TEST62 = hello # comment
91-
TEST63 = "hello # comment"
92-
TEST64 = "hello" #comment
90+
TEST63 = hello # comment
91+
TEST64 = "hello # comment"
92+
TEST65 = "hello" #comment
9393
TEST66 = #comment
9494
TEST67 = "#comment"

0 commit comments

Comments
 (0)