https://github.com/bauhausphp/config
PSR-11 configuration container
https://github.com/bauhausphp/config
config container php72 psr-11
Last synced: about 1 month ago
JSON representation
PSR-11 configuration container
- Host: GitHub
- URL: https://github.com/bauhausphp/config
- Owner: bauhausphp
- License: mit
- Created: 2016-12-28T00:33:01.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-03T21:24:50.000Z (about 7 years ago)
- Last Synced: 2025-01-19T21:49:31.039Z (3 months ago)
- Topics: config, container, php72, psr-11
- Language: PHP
- Homepage:
- Size: 59.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/bauhausphp/config)
[](https://coveralls.io/github/bauhausphp/config?branch=master)
[](https://www.codacy.com/app/bauhausphp/config)[](https://packagist.org/packages/bauhaus/config)
[](https://packagist.org/packages/bauhaus/config)
[](https://packagist.org/packages/bauhaus/config)
[](https://packagist.org/packages/bauhaus/config)> **Warning!** This package won't worry about backward compatibily for `v0.*`.
# Bauhaus Config
Bauhaus Config aims to provide a simple way to load and validate configurations
via a container implementation of [PSR-11](http://www.php-fig.org/psr/psr-11/).## TODOS
This package isn't still complete. Missing features are:
* Validate configuration schema (use JSON schema)
* Load from `yaml` (It will be done in a new repository bauhaus/config-yaml)## Motivation
It's annoying when something inside your application breaks just because a
configuration entry was missing.To prevent it, Bauhaus Config validates when the configurations are loaded
(being implemented).## Usage
```php
'bass',
'pokemons' => ['charmander', 'pikachu'],
'books' => [
'study' => ['Clean Code', 'GOOS', 'Design Patterns'],
],
]);$config instanceof PsrContainer; // true
$config->has('instrument'); // true
$config->has('pokemons'); // true
$config->has('books.study'); // true
$config->has('cars'); // false
$config->has('travels.asia'); // false$config->get('instrument'); // 'bass'
$config->get('pokemons'); // ['charmander', 'pikachu']
$config->get('books'); // Config(['study' => ['Clean Code', 'GOOS', 'Design Patterns']])
$config->get('cars'); // throw NotFoundException implementing PsrNotFoundException
$config->get('travels.asia'); // throw NotFoundException implementing PsrNotFoundException$config->get('books')->has('study'); // true
```## Installation
Install it using [Composer](https://getcomposer.org/):
```shell
$ composer require bauhaus/config
```## Coding Standard and Testing
This code has two levels of testing:
1. Coding standard (using PHPCS with PSR-2 standard):
```shell
$ composer run test:cs
```2. Unit tests (using PHPUnit):
```shell
$ composer run test:unit
```To run all at one:
```shell
$ composer run tests
```