Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bauhausphp/config
PSR-11 configuration container
https://github.com/bauhausphp/config
config container php72 psr-11
Last synced: 20 days 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 (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-03T21:24:50.000Z (almost 7 years ago)
- Last Synced: 2024-11-13T00:53:14.527Z (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
[![Build Status](https://img.shields.io/travis/bauhausphp/config/master.svg?style=flat-square)](https://travis-ci.org/bauhausphp/config)
[![Coverage Status](https://img.shields.io/coveralls/bauhausphp/config/master.svg?style=flat-square)](https://coveralls.io/github/bauhausphp/config?branch=master)
[![Codacy Badge](https://img.shields.io/codacy/534139d09a5941ecbfcb9dd922e30111.svg?style=flat-square)](https://www.codacy.com/app/bauhausphp/config)[![Latest Stable Version](https://poser.pugx.org/bauhaus/config/v/stable?format=flat-square)](https://packagist.org/packages/bauhaus/config)
[![Latest Unstable Version](https://poser.pugx.org/bauhaus/config/v/unstable?format=flat-square)](https://packagist.org/packages/bauhaus/config)
[![Total Downloads](https://poser.pugx.org/bauhaus/config/downloads?format=flat-square)](https://packagist.org/packages/bauhaus/config)
[![composer.lock](https://poser.pugx.org/bauhaus/config/composerlock?format=flat-square)](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
```