-
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
0 parents
commit 945b76e
Showing
14 changed files
with
3,751 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,8 @@ | ||
root=true | ||
|
||
[*] | ||
end_of_line=lf | ||
indent_style=tab | ||
indent_size=4 | ||
charset=utf-8 | ||
trim_trailing_whitespace=true |
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,3 @@ | ||
vendor/ | ||
build/ | ||
.phpunit.result.cache |
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,12 @@ | ||
language: php | ||
php: | ||
- '7.2' | ||
|
||
install: | ||
- composer install | ||
|
||
script: | ||
- make coverage | ||
|
||
after_success: | ||
- travis_retry php vendor/bin/php-coveralls |
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,13 @@ | ||
.PHONY: release | ||
|
||
test: | ||
vendor/bin/phpunit | ||
|
||
coverage: | ||
vendor/bin/phpunit --coverage-clover=build/logs/clover.xml | ||
|
||
analyze: | ||
vendor/bin/psalm | ||
|
||
release: | ||
/usr/bin/env php release |
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,68 @@ | ||
# Config | ||
|
||
A simple configuration manager with lazy loading from files. | ||
|
||
## Installation | ||
|
||
```bash | ||
composer require nimbly/config | ||
``` | ||
|
||
## Configuration files | ||
|
||
Configuration files should return an associative array with the settings of your choice. | ||
|
||
```php | ||
<?php | ||
|
||
return [ | ||
"host" => "localhost", | ||
"port" => 1234, | ||
"user" => "dbuser", | ||
"password" => "dbpassword", | ||
]; | ||
``` | ||
|
||
## Usage | ||
|
||
Instantiate the ```Config``` manager with the location on disk to your configuration files. | ||
|
||
```php | ||
$config = new Config(__DIR__ . "/config"); | ||
``` | ||
|
||
## Accessing values | ||
|
||
Configuration keys can be accessed using a dot-notation syntax with the left most being the root file name of the configuration file. | ||
|
||
```php | ||
$config->get('database.host'); | ||
``` | ||
|
||
The above would load the contents of the file ```database.php``` from the configuration path passed into the ```Config``` manager. | ||
|
||
Your configuration files may contain nested associative arrays that can be accessed using the same dotted notation. | ||
|
||
```php | ||
$config->get("database.connections.default.host"); | ||
``` | ||
|
||
## Default values | ||
|
||
When getting keys from the config manager, you can optionally define a default value. | ||
|
||
```php | ||
$config->get('database.host', 'localhost'); | ||
``` | ||
|
||
## Manually adding values | ||
|
||
You may also manually add new key / value pairs into the configuration manager. | ||
|
||
```php | ||
$config->add('queue', [ | ||
'name' => 'jobs', | ||
'host' => 'localhost', | ||
'port' => 1234 | ||
]); | ||
``` |
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,26 @@ | ||
{ | ||
"name": "nimbly/config", | ||
"description": "Configuration and settings manager with autoloading from disk.", | ||
"type": "library", | ||
"require-dev": { | ||
"phpunit/phpunit": "^8.3", | ||
"vimeo/psalm": "^3.4", | ||
"symfony/var-dumper": "^4.3", | ||
"php-coveralls/php-coveralls": "^2.1" | ||
}, | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Brent Scheffler", | ||
"email": "brent@brentscheffler.com" | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.2" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"nimbly\\Config\\": "src\/" | ||
} | ||
} | ||
} |
Oops, something went wrong.