2017 © Pedro Peláez
 

library weblibs-configmanager

weblibs-configmanager is a tool library for easily read and access to php config array file and direct read/write configuration file / object

image

clagiordano/weblibs-configmanager

weblibs-configmanager is a tool library for easily read and access to php config array file and direct read/write configuration file / object

  • Tuesday, August 23, 2016
  • by clagiordano
  • Repository
  • 1 Watchers
  • 0 Stars
  • 113 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 157 % Grown

The README.md

PHP Composer Coverage Status SymfonyInsight, (*1)

weblibs-configmanager

weblibs-configmanager is a tool library for easily read and access to php config array file and direct read/write configuration file / object., (*2)

Why use weblibs-configmanager ?

The purpose of this project is to propose a simple and lightweight library to manage php hierarchical configuration files., (*3)

Supported formats

This package supports config files in the following format:, (*4)

Format Component Since version Description
Array ConfigManager v0.1.0 Deprecated, legacy name for the php array reader, only for compatibility support
Array ArrayConfigManager v1.2.0 A file that returns a php array, the original supported format
Yaml YamlConfigManager v1.3.0 A file containing a valid YAML file
JSON JsonConfigManager v1.4.0 A file containing a valid JSON file

All the supported format are parsed and internally handled in the same way granting the same functionalities., (*5)

Installation

The recommended way to install weblibs-configmanager is through Composer., (*6)

composer require clagiordano/weblibs-configmanager

Usage examples (Array format)

Write a sample config file like this

<?php

return array (
  'app' => 'app_name',
  'db' => 
  array (
    'host' => 'localhost',
    'user' => 'sample_user',
    'pass' => 'sample_pass',
    'port' => 3306,
  ),
  'other' => 
  array (
    'multi' => 
    array (
      'deep' => 
      array (
        'nested' => 'config_value',
      ),
    ),
  ),
);

Instance ConfigManager object

use clagiordano\weblibs\configmanager\ConfigManager;

/**
 * Instance object to read argument file
 */
$config = new ConfigManager("configfile.php");

Check if a value exists into config file

/**
 * Check if a value exists into config file
 */
$value = $config->existValue('app');

Read a simple element from config file

/**
 * Read a simple element from config file
 */
$value = $config->getValue('app');

Access to a nested element from config

/**
 * Access to a nested element from config
 */
$nestedValue = $config->getValue('other.multi.deep.nested');

Change config value at runtime

/**
 * Change config value at runtime
 */
$this->config->setValue('other.multi.deep.nested', "SUPERNESTED");

Save config file with original name (OVERWRITE)

/**
 * Save config file with original name (OVERWRITE) 
 */
$this->config->saveConfigFile();

Or save config file with a different name

/**
 * Save config file with original name (OVERWRITE) 
 */
$this->config->saveConfigFile('/new/file/name/or/path/test.php');

Optionally you can also reload config file from disk after save

/**
 * Optionally you can also reload config file from disk after save
 */
$this->config->saveConfigFile('/new/file/name/or/path/test.php', true);

Load another configuration file without reinstance ConfigManager

/**
 * Load another configuration file without reinstance ConfigManager
 */
$this->config->loadConfig('another_config_file.php');

Copyright (C) Claudio Giordano claudio.giordano@autistici.org, (*7)

The Versions

23/08 2016

dev-master

9999999-dev

weblibs-configmanager is a tool library for easily read and access to php config array file and direct read/write configuration file / object

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4

 

The Development Requires

by Claudio Giordano

configuration manager tool clagiordano weblibs

23/08 2016

v1.0.6

1.0.6.0

weblibs-configmanager is a tool library for easily read and access to php config array file and direct read/write configuration file / object

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4

 

The Development Requires

by Claudio Giordano

configuration manager tool clagiordano weblibs

23/08 2016

v1.0.5

1.0.5.0

weblibs-configmanager is a tool library for easily read and access to php config array file and direct read/write configuration file / object

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4

 

The Development Requires

by Claudio Giordano

configuration manager tool clagiordano weblibs

23/08 2016

v1.0.4

1.0.4.0

weblibs-configmanager is a tool library for easily read and access to php config array file and direct read/write configuration file / object

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.3

 

The Development Requires

by Claudio Giordano

configuration manager tool clagiordano weblibs

18/08 2016

v1.0.3

1.0.3.0

weblibs-configmanager is a tool library for easily read and access to php config array file and direct read/write configuration file / object

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.3

 

The Development Requires

17/08 2016

v1.0.2

1.0.2.0

weblibs-configmanager is a tool library for easily read and access to php config array file and direct read/write configuration file / object

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.3

 

The Development Requires

17/08 2016

v1.0.1

1.0.1.0

weblibs-configmanager is a tool library for easily read and access to php config array file and direct read/write configuration file / object

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.3

 

The Development Requires

17/08 2016

v1.0

1.0.0.0

weblibs-configmanager is a tool library for easily read and access to php config array file and direct read/write configuration file / object

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.3

 

The Development Requires

17/08 2016

v0.1

0.1.0.0

weblibs-configmanager is a tool library for easily read and access to php config array file and direct read/write configuration file / object

  Sources   Download

LGPL-3.0

The Requires

  • php >=5.4

 

The Development Requires