-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
chthomas
committed
May 24, 2020
0 parents
commit 66c8b97
Showing
32 changed files
with
4,870 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
composer.phar | ||
/vendor/ | ||
/coverage/ | ||
/.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
build: | ||
environment: | ||
php: | ||
version: '7.4.1' | ||
nodes: | ||
my-tests: | ||
environment: | ||
php: | ||
version: '7.4.1' | ||
cache: | ||
disabled: true | ||
|
||
dependencies: | ||
override: | ||
- composer install --ignore-platform-reqs --no-interaction | ||
|
||
build_failure_conditions: | ||
- 'elements.rating(<= B).new.exists' # No new classes/methods with a rating of C or worse allowed | ||
- 'project.metric_change("scrutinizer.test_coverage", < 0)' # Code Coverage decreased from previous inspection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
notifications: | ||
email: false | ||
|
||
language: php | ||
|
||
php: | ||
- '7.4' | ||
|
||
install: | ||
- composer install | ||
|
||
script: | ||
- make | ||
- mkdir -p build/logs | ||
- vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover build/logs/clover.xml | ||
|
||
after_success: | ||
- travis_retry php vendor/bin/php-coveralls -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
MIT License | ||
|
||
Copyright (c) 2017 Christian Thomas <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
.PHONY: dependencies, unit-tests, integration-tests, test-coverage, style-check, dependency-check, static-analysis, style-fix | ||
build: | ||
@make dependencies && make dependency-check && make static-analysis && make style-check && make unit-tests && make integration-tests | ||
|
||
dependencies: | ||
@composer install | ||
|
||
unit-tests: | ||
@vendor/bin/phpunit --bootstrap=./tests/bootstrap.php --testsuite Unit | ||
|
||
integration-tests: | ||
@vendor/bin/phpunit --bootstrap=./tests/bootstrap.php --testsuite Integration | ||
|
||
test-coverage: | ||
@vendor/bin/phpunit --coverage-html ./coverage | ||
|
||
style-check: | ||
@vendor/bin/phpcs --standard=PSR12 ./src/* ./tests/* | ||
|
||
dependency-check: | ||
@vendor/bin/composer-require-checker check -vvv ./composer.json | ||
|
||
static-analysis: | ||
@vendor/bin/psalm --show-info=false | ||
|
||
style-fix: | ||
@vendor/bin/phpcbf --standard=PSR12 ./src ./tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
[![Build Status](https://travis-ci.com/remotelyliving/php-env.svg?branch=master)](https://travis-ci.org/remotelyliving/php-env) | ||
[![Total Downloads](https://poser.pugx.org/remotelyliving/php-env/downloads)](https://packagist.org/packages/remotelyliving/php-env) | ||
[![Coverage Status](https://coveralls.io/repos/github/remotelyliving/php-env/badge.svg?branch=master)](https://coveralls.io/github/remotelyliving/php-env?branch=master) | ||
[![License](https://poser.pugx.org/remotelyliving/php-env/license)](https://packagist.org/packages/remotelyliving/php-env) | ||
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/remotelyliving/php-env/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/remotelyliving/php-env/?branch=master) | ||
|
||
# php-env | ||
### 🌎 An Environment Abstraction for PHP 🌎 | ||
|
||
### Use Cases | ||
|
||
If you want a boundary between you and your runtime environment, this library can help. | ||
If you like to use .env files this library can help. | ||
|
||
### Installation | ||
|
||
```sh | ||
composer require remotelyliving/php-env | ||
``` | ||
|
||
### Usage | ||
|
||
#### Create The Application Environment | ||
|
||
```php | ||
<?php | ||
// needs to be set before hand through docker or could grab the app environment from cli args | ||
// EnvironmentType is an enum that you can extend to add more values to | ||
$envType = new EnvironmentType(getenv('ENVIRONMENT')); | ||
$envFile = "/my/app/envs/.{$envType}.env"; | ||
|
||
// we can now create the app environment | ||
$env = Environment::createWithEnvFile($envType, $envFile); | ||
|
||
// tells you which environment you're in | ||
$env->is(EnvironmentType::DEVELOPMENT()); // true | ||
$env->is(EnvironmentType::PRODUCTION()); // false | ||
|
||
// tells you if a var exists | ||
$env->has('FOO'); // true | ||
|
||
// returns a value caster of a value that can then be called to get stricter types | ||
$env->get('FOO')->asArray(); | ||
$env->get('BAR')->asBoolean(); | ||
$env->get('BAR')->asInteger(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "remotelyliving/php-env", | ||
"description": "A library to marshall environment variables from environments", | ||
"keywords": ["env", "dotenv", "getenv", "environment"], | ||
"type": "library", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Christian Thomas", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"minimum-stability": "stable", | ||
"require": { | ||
"php": ">=7.4", | ||
"ext-json": "*", | ||
"ext-filter": "*", | ||
"ext-mbstring": "*", | ||
"myclabs/php-enum": "^1.0" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^9.0", | ||
"maglnet/composer-require-checker": "^2.0", | ||
"squizlabs/php_codesniffer": "^3.3", | ||
"php-coveralls/php-coveralls": "^2.2", | ||
"vimeo/psalm": "^3.7" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"RemotelyLiving\\PHPEnv\\" : "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"RemotelyLiving\\PHPEnv\\Tests\\" : "tests/" | ||
} | ||
} | ||
} |
Oops, something went wrong.