2017-25 © Pedro Peláez
 

library config

Simple config container

image

bauhaus/config

Simple config container

  • Tuesday, April 3, 2018
  • by fefas
  • Repository
  • 1 Watchers
  • 0 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Build Status Coverage Status Codacy Badge, (*1)

Latest Stable Version Latest Unstable Version Total Downloads composer.lock, (*2)

Warning! This package won't worry about backward compatibily for v0.*., (*3)

Bauhaus Config

Bauhaus Config aims to provide a simple way to load and validate configurations via a container implementation of PSR-11., (*4)

TODOS

This package isn't still complete. Missing features are:, (*5)

  • 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., (*6)

To prevent it, Bauhaus Config validates when the configurations are loaded (being implemented)., (*7)

Usage

<?php

use Psr\Container\NotFoundExceptionInterface as PsrNotFoundException;
use Psr\Container\ContainerInterface as PsrContainer;
use Bauhaus\Config;
use Bauhaus\Config\NotFoundException;

$config = new Config([
    'instrument' => '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:, (*8)

$ composer require bauhaus/config

Coding Standard and Testing

This code has two levels of testing:, (*9)

  1. Coding standard (using PHPCS with PSR-2 standard):, (*10)

    $ composer run test:cs
    
  2. Unit tests (using PHPUnit):, (*11)

    $ composer run test:unit
    

To run all at one:, (*12)

$ composer run tests

The Versions

03/04 2018

dev-extract-loader

dev-extract-loader

Simple config container

  Sources   Download

MIT

The Requires

 

The Development Requires

container configuration config bauhaus

11/02 2018

dev-master

9999999-dev

Simple config container

  Sources   Download

MIT

The Requires

 

The Development Requires

container configuration config bauhaus

11/02 2018

v0.1.0

0.1.0.0

Simple config container

  Sources   Download

MIT

The Requires

 

The Development Requires

container configuration config bauhaus

11/02 2018

dev-redo

dev-redo

Simple config container

  Sources   Download

MIT

The Requires

 

The Development Requires

container configuration config bauhaus

05/01 2017

v0.0.1

0.0.1.0

Simple configuration container.

  Sources   Download

MIT

The Requires

 

The Development Requires

configuration config bauhaus

31/12 2016

v0.0.0

0.0.0.0

Simple configuration container.

  Sources   Download

MIT

The Requires

 

The Development Requires

configuration config bauhaus