Skip to content

Commit 3ed76f4

Browse files
committed
First
0 parents  commit 3ed76f4

32 files changed

+1354
-0
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; This file is for unifying the coding style for different editors and IDEs.
2+
; More information at http://editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
charset = utf-8
8+
indent_size = 4
9+
indent_style = space
10+
end_of_line = lf
11+
insert_final_newline = true
12+
trim_trailing_whitespace = true
13+
14+
[*.md]
15+
trim_trailing_whitespace = false

.gitattributes

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Path-based git attributes
2+
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
3+
4+
# Ignore all test and documentation with "export-ignore".
5+
/.gitattributes export-ignore
6+
/.gitignore export-ignore
7+
/.travis.yml export-ignore
8+
/phpunit.xml.dist export-ignore
9+
/.scrutinizer.yml export-ignore
10+
/tests export-ignore

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.idea
2+
build
3+
composer.lock
4+
docs
5+
vendor
6+
/output

.scrutinizer.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
filter:
2+
excluded_paths: [tests/*, vendor]
3+
4+
checks:
5+
php:
6+
code_rating: true
7+
remove_extra_empty_lines: true
8+
remove_php_closing_tag: true
9+
remove_trailing_whitespace: true
10+
fix_use_statements:
11+
remove_unused: true
12+
preserve_multiple: false
13+
preserve_blanklines: true
14+
order_alphabetically: true
15+
fix_php_opening_tag: true
16+
fix_linefeed: true
17+
fix_line_ending: true
18+
fix_identation_4spaces: true
19+
fix_doc_comments: true
20+
21+
tools:
22+
external_code_coverage:
23+
timeout: 600
24+
runs: 3

.travis.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
language: php
2+
3+
php:
4+
- 5.4
5+
- 5.5
6+
- 5.6
7+
- 7.0
8+
- hhvm
9+
10+
# This triggers builds to run on the new TravisCI infrastructure.
11+
# See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/
12+
sudo: false
13+
14+
matrix:
15+
allow_failures:
16+
- php: 7.0
17+
include:
18+
- php: 5.4
19+
env: 'COMPOSER_FLAGS="--prefer-stable --prefer-lowest"'
20+
21+
before_script:
22+
- travis_retry composer self-update
23+
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source
24+
25+
script:
26+
- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
27+
28+
after_script:
29+
- if [[ $TRAVIS_PHP_VERSION != 'hhvm' && $TRAVIS_PHP_VERSION != '7.0' ]]; then php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover; fi

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changelog
2+
3+
All Notable changes to `Env` will be documented in this file
4+
5+
## 0.1.0 - 2015-12-13
6+
### Added
7+
- Initial Release

CONDUCT.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Contributor Code of Conduct
2+
3+
As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4+
5+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
6+
7+
Examples of unacceptable behavior by participants include:
8+
9+
* The use of sexualized language or imagery
10+
* Personal attacks
11+
* Trolling or insulting/derogatory comments
12+
* Public or private harassment
13+
* Publishing other's private information, such as physical or electronic addresses, without explicit permission
14+
* Other unethical or unprofessional conduct.
15+
16+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.
17+
18+
This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community in a direct capacity. Personal views, beliefs and values of individuals do not necessarily reflect those of the organisation or affiliated individuals and organisations.
19+
20+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
21+
22+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)

CONTRIBUTING.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Contributing
2+
3+
Contributions are **welcome** and will be fully **credited**.
4+
5+
We accept contributions via Pull Requests on [Github](https://github.com/m1/env).
6+
7+
8+
## Pull Requests
9+
10+
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - Check the code style with ``$ composer check-codestyle`` and fix it with ``$ composer fix-codestyle``.
11+
12+
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
13+
14+
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
15+
16+
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
17+
18+
- **Create feature branches** - Don't ask us to pull from your master branch.
19+
20+
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
21+
22+
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
23+
24+
25+
## Running Tests
26+
27+
``` bash
28+
$ composer test
29+
```
30+
31+
32+
**Happy coding**!

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# The MIT License (MIT)
2+
3+
Copyright (c) 2015 Miles Croxford <[email protected]>
4+
5+
> Permission is hereby granted, free of charge, to any person obtaining a copy
6+
> of this software and associated documentation files (the "Software"), to deal
7+
> in the Software without restriction, including without limitation the rights
8+
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
> copies of the Software, and to permit persons to whom the Software is
10+
> furnished to do so, subject to the following conditions:
11+
>
12+
> The above copyright notice and this permission notice shall be included in
13+
> all copies or substantial portions of the Software.
14+
>
15+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
> THE SOFTWARE.

README.md

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# Env
2+
3+
[![Latest Version on Packagist][ico-version]][link-packagist]
4+
[![Software License][ico-license]](LICENSE.md)
5+
[![Build Status][ico-travis]][link-travis]
6+
[![Coverage Status][ico-scrutinizer]][link-scrutinizer]
7+
[![Quality Score][ico-code-quality]][link-code-quality]
8+
[![Total Downloads][ico-downloads]][link-downloads]
9+
10+
Env is a lightweight library bringing .env file parser compatibility to PHP. In short - it enables you to read .env files with PHP.
11+
12+
Env aims to bring a unified parser for env together for PHP rather than having a few incomplete or buggy parsers written into other libraries. This library is not meant as a complete package for config loading like other libraries as this is out of scope for this library. If you need something like that check out [Vars](http://github.com/m1/Vars)
13+
14+
## Install
15+
16+
Via Composer
17+
18+
``` bash
19+
$ composer require m1/env
20+
```
21+
22+
## Usage
23+
24+
### Basic
25+
26+
test.env
27+
```env
28+
TEST_1 = VALUE
29+
```
30+
31+
example.php
32+
``` php
33+
34+
//both examples return the same thing
35+
36+
// example 1 -- standard
37+
$env = new M1\Env('test.env');
38+
$arr = $env->getContents();
39+
40+
// example 2 -- statically
41+
$arr = Env::parse('test.env');
42+
43+
var_dump($arr);
44+
// [
45+
// "TEST_1" => "VALUE"
46+
// ]
47+
```
48+
49+
### .env examples
50+
51+
```env
52+
# Comments are done like this
53+
54+
# Standard key=value
55+
KEY = value
56+
KEY = value
57+
KEY = value # You can also comment inline like this
58+
59+
# Strings
60+
KEY = "value"
61+
62+
## The value of the below variable will be TK4 = "value value"
63+
KEY = "value value" "this sentence in quotes will not be counted"
64+
65+
## Escape newline
66+
KEY = "value \n value"
67+
68+
## Escape double quotes
69+
KEY = "value \"value\" value"
70+
71+
## You can also exchange any of the above for single quotes, eg:
72+
KEY = 'value'
73+
74+
# Numbers
75+
KEY = 1
76+
KEY = 1.1
77+
KEY = 33 33 # Will output as a string -- not a number as two numbers are given
78+
79+
# Bools -- All of the below are valid booleans
80+
KEY = true
81+
KEY = false
82+
KEY = yes
83+
KEY = no
84+
85+
## Booleans are case-insensitive
86+
KEY = True
87+
KEY = False
88+
KEY = YES
89+
KEY = NO
90+
91+
# Null values
92+
KEY =
93+
KEY = null
94+
95+
# Variables
96+
string_1 = 'hello'
97+
test_variable_1 = ${string_1} # Hello
98+
99+
int_1 = 1
100+
int_2 = 2
101+
test_variable_1 = ${int_1} # 1 -- `int` type
102+
test_variable_2 = "${int_1}" # 1 -- `string` type
103+
test_variable_2 = ${int_1} ${int_2} # 1 2 -- `string` type
104+
105+
string_1 = foo
106+
string_2 = bar
107+
test_variable_1 = ${string_1}/${string_2} # foo/bar -- `string` type
108+
109+
string_3 = "foo"
110+
string_4 = 'bar'
111+
test_variable_1 = "hello ${string_3} and ${string_4}" # hello foo and bar -- `string` type
112+
113+
bool_1 = true
114+
bool_2 = false
115+
test_variable_1 = ${bool_1} # true -- `bool` type
116+
test_variable_2 = ${bool_1} ${bool_2} # true false -- `string` type
117+
```
118+
119+
## Change log
120+
121+
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
122+
123+
## Testing
124+
125+
``` bash
126+
$ composer test
127+
```
128+
129+
## Contributing
130+
131+
Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.
132+
133+
## Security
134+
135+
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
136+
137+
## Credits
138+
139+
- [m1][link-author]
140+
- [All Contributors][link-contributors]
141+
142+
## License
143+
144+
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
145+
146+
[ico-version]: https://img.shields.io/packagist/v/m1/Env.svg?style=flat-square
147+
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
148+
[ico-travis]: https://img.shields.io/travis/m1/Env/master.svg?style=flat-square
149+
[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/m1/Env.svg?style=flat-square
150+
[ico-code-quality]: https://img.shields.io/scrutinizer/g/m1/Env.svg?style=flat-square
151+
[ico-downloads]: https://img.shields.io/packagist/dt/m1/Env.svg?style=flat-square
152+
153+
[link-packagist]: https://packagist.org/packages/m1/Env
154+
[link-travis]: https://travis-ci.org/m1/Env
155+
[link-scrutinizer]: https://scrutinizer-ci.com/g/:vendor/Env/code-structure
156+
[link-code-quality]: https://scrutinizer-ci.com/g/m1/Env
157+
[link-downloads]: https://packagist.org/packages/m1/Env
158+
[link-author]: https://github.com/m1
159+
[link-contributors]: ../../contributors

0 commit comments

Comments
 (0)