newclass/pactum

The Php config manager.

v1.4.0 2016-12-11 10:18 UTC

This package is auto-updated.

Last update: 2024-09-16 22:16:51 UTC


README

license PHP 5.5+

What is Pactum?

Pactum is a PHP config manager. Support multi file types.

Installation

The best way to install is to use the composer by command:

composer require newclass/pactum
composer install

Use example

use Pactum\ConfigBuilder;
use Pactum\ConfigBuilderObject;
use Pactum\Reader\JSONReader;

$config=new ConfigBuilder();

//set config structure
$config->addBoolean("booleanTrue")
    ->addNumber("number1")
    ->addString("text")
    ->addString("other","default")
    ->addArray("d_array",new ConfigBuilderObject())
    ->getValue()->addString("test");

//add json reader
$xmlReader=new JSONReader('{"booleanTrue":true,"number1":1,"text":"value text","d_array":[{"test":"wdwd"}]}','s');
$config->addReader($xmlReader);
//parse data and generate container
$container=$config->parse();

//get value from config data
$valueBoolean=$container->getValue('booleanTrue');
$valueArray=$container->getArray("d_array");

//or get object with getters
$obj=$container->getConfig();
$obj->getNumber1(); //return 1