2017 © Pedro PelĂĄez
 

library config

Simple configuration file loader

image

rkulik/config

Simple configuration file loader

  • Wednesday, April 18, 2018
  • by rkulik
  • Repository
  • 1 Watchers
  • 1 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 100 % Grown

The README.md

config

Lightweight configuration file loader. Currently supporting PHP and JSON files., (*1)

Requirements

This package requires PHP 7.1 or higher., (*2)

Install

Via composer:, (*3)

``` bash $ composer require rkulik/config, (*4)


## Usage ### Instantiate basic configuration ``` php <?php // config.php return [ 'hello' => 'world', ];

``` php <?php // index.php, (*5)

require 'vendor/autoload.php';, (*6)

$configFactory = new \Rkulik\Config\ConfigFactory();, (*7)

$config = $configFactory->make('config.php');, (*8)

echo $config->get('hello'); // world, (*9)


### Instantiate configuration using custom parser For special requirements, such as working with unsupported types of configuration files, using a custom parser is the suggested way to go. ``` php <?php // config.php return [ 'hello' => 'world', ];

``` php <?php // CustomParser.php, (*10)

use Rkulik\Config\FileParser\FileParserInterface;, (*11)

class CustomParser implements FileParserInterface { /** * {@inheritdoc} */ public function parse(string $file): array { $data = require $file;, (*12)

    array_walk($data, function (&$item) {
        $item = strrev($item);
    });

    return $data;
}

}, (*13)


``` php <?php // index.php require 'vendor/autoload.php'; require 'CustomParser.php'; $configFactory = new \Rkulik\Config\ConfigFactory(); $customParser = new CustomParser(); $config = $configFactory->make('config.php', $customParser); echo $config->get('hello'); // dlrow

Using "dot" notation

Use "dot" notation to perform CRUD operations on configuration data., (*14)

``` php <?php // config.php, (*15)

return [ 'hello' => [ 'beautiful' => 'world', ], ];, (*16)


``` php <?php // index.php require 'vendor/autoload.php'; $configFactory = new \Rkulik\Config\ConfigFactory(); $config = $configFactory->make('config.php'); echo $config->get('hello.beautiful'); // world

Testing

bash $ composer test, (*17)

Changelog

Please see CHANGELOG for more information what has changed recently., (*18)

Contributing

Please see CONTRIBUTING for details., (*19)

Security

If you discover any security-related issues, please email rene@kulik.io instead of using the issue tracker., (*20)

Credits

License

The MIT License (MIT). Please see License File for more information., (*21)

The Versions

18/04 2018

dev-master

9999999-dev https://github.com/rkulik/config

Simple configuration file loader

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

php config rkulik

18/04 2018

1.2.0

1.2.0.0 https://github.com/rkulik/config

Simple configuration file loader

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

php config rkulik

18/04 2018

1.1.0

1.1.0.0 https://github.com/rkulik/config

Simple configuration file loader

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

php config rkulik

01/04 2018

1.0.0

1.0.0.0 https://github.com/rkulik/config

Simple configuration file loader

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

php config rkulik