2017 © Pedro Peláez
 

library config-52

Minimal, reusable Config component (without namespaces)

image

brightnucleus/config-52

Minimal, reusable Config component (without namespaces)

  • Thursday, March 31, 2016
  • by schlessera
  • Repository
  • 1 Watchers
  • 0 Stars
  • 30 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Bright Nucleus Config 5.2

Config component that does not use namespaces, to be used in PHP 5.2 projects., (*1)

Latest Stable Version Total Downloads Latest Unstable Version License, (*2)

Table Of Contents

Introduction

Bright Nucleus Config 5.2 is a Config component similar to brightnucleus/config, but it does not use PHP namespaces, so that it can be used in projects that need to work on PHP 5.2., (*3)

As it uses Composer, it will need PHP 5.3.2+ to use during development. However, there's a PHP 5.2 autoloader file that is generated, so that you only need PHP 5.2+ at runtime., (*4)

This is a very reduced form of a Config component, though, and is meant to provide a very basic way for PHP 5.2 libraries to read existing config files. There's no default values, no validation, no fancy convenience functions., (*5)

Installation

To include the library in your project, you can use Composer:, (*6)

composer require brightnucleus/config-52

Alternatively, you can copy the classes inside of your application and make sure that your application can find them., (*7)

Basic Usage

To use the component within your project, you should first load the 5.2 autoloader:, (*8)

require dirname(__FILE__) . '/vendor/autoload_52.php';

Here's an example of how to use the class once it's been loaded:, (*9)

<?php

use BrightNucleus_ConfigInterface as ConfigInterface;
use BrightNucleus_Config          as Config;

class WorldGreeter {

    /** @var  @var ConfigInterface */
    protected $config;

    public function __construct(ConfigInterface $config) {
        $this->config = $config;
    }

    public function greet() {
        $hello = $this->config->getKey('hello');
        $world = $this->config->getKey('world');
        echo "$hello $world";
    }
}

$config_file = dirname(__FILE__) . '/config/greetings.php';
$config      = new Config(include($config_file));

$worldGreeter = new WorldGreeter($config);
$worldGreeter->greet();

Contributing

All feedback / bug reports / pull requests are welcome., (*10)

License

This code is released under the MIT license. For the full copyright and license information, please view the LICENSE file distributed with this source code., (*11)

The Versions

31/03 2016

dev-master

9999999-dev

Minimal, reusable Config component (without namespaces)

  Sources   Download

MIT

The Requires

 

The Development Requires

31/03 2016

v0.1.0

0.1.0.0

Minimal, reusable Config component (without namespaces)

  Sources   Download

MIT

The Requires

 

The Development Requires