PHP Config Class from Files in JSON, INI, XML, YAML, NEON or Arrays: Read configuration from multiple file formats

Recommend this page to a friend!
  Info   View files Documentation   View files View files (48)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2021-09-25 (Yesterday) RSS 2.0 feedNot yet rated by the usersTotal: 113 All time: 9,358 This week: 181Up
Version License PHP version Categories
php-config 1.1.0Freely Distributable7.4PHP 5, Files and Folders, Configuration
Description Author

This package can read configuration from JSON, INI, XML, YAML, NEON and arrays.

It provides separate classes that can parse configuration files in all the supported formats.

The classes provide functions to get the configuration values passing keys that specify which values are need by the applications that use these classes.

It is also possible to merge configuration values read from several configuration files.

Picture of Stefan Kientzler
  Performance   Level  
Name: Stefan Kientzler <contact>
Classes: 16 packages by
Country: Germany Germany
Innovation award
Innovation award
Nominee: 9x

Winner: 6x

Details

Read and merge configuration files of different formats

Latest Stable Version License Donate Minimum PHP Version Scrutinizer Code Quality codecov

New in Version 1.1.0

  • Added support for YAML and NEON config files
  • New method `setPathSeparator()` to change default path separator ('.')

Overview

This package provides a general interface that grant access to configuration settings of different sources and/or formats.

Following Formats are supported so far:

  • JSON
  • INI (flat INI file like 'usual' windwos INI-Files supporting sections and entries)
  • XML
  • YAML
  • NEON
  • directly from an Array (content may result from a DB query)

In addition, the package offers the possibility of merging several configurations from different sources and / or in different formats into one object, which can then be used by any module.

There is thus the possibility of e.g. Merge global and local or general and user-specific configurations without the processing module having to know where what information comes from.

A NullConfig class is also included that can be used for testing. Also this class can be used if it is desired to make a module working completly independent with default configuration values and optional can have external configuration be passed.

Usage

  1. Create an instance of the class that supports the desired format.
  2. Pass this instance to any module that supports the `ConfigInterface`
  3. inside the module get the needed config settings with `the getXXX($strPath, $default)` - Methods

See ConfigExample.php

For the format of the configuration files see the seeral examples comming with this package.

History

2021-01-05 Version 1.0.0
  • initial Version
2021-08-01 Version 1.1.0
  • Added support for YAML and NEON config files
  • New method setPathSeparator() to change default path separator ('.')
  Files folder image Files  
File Role Description
Files folder imageNette (1 directory)
Files folder imageSKien (2 directories)
Accessible without login Plain text file autoloader.php Aux. Auxiliary script
Accessible without login Plain text file ConfigExample.php Example Example script
Accessible without login Plain text file ExampleConfig.ini Data Auxiliary data
Accessible without login Plain text file ExampleConfig.json Data Auxiliary data
Accessible without login Plain text file ExampleConfig.neon Data Auxiliary data
Accessible without login Plain text file ExampleConfig.xml Data Auxiliary data
Accessible without login Plain text file ExampleConfig.yaml Data Auxiliary data
Accessible without login Plain text file githubwiki.xml Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file MergeExample.php Example Example script
Accessible without login Plain text file MergeExample1.json Data Auxiliary data
Accessible without login Plain text file MergeExample2.json Data Auxiliary data
Accessible without login Plain text file phpstan.neon Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file readme.md Doc. Documentation

  Files folder image Files  /  Nette  
File Role Description
Files folder imageNeon (5 files)

  Files folder image Files  /  Nette  /  Neon  
File Role Description
  Plain text file Decoder.php Class Class source
  Plain text file Encoder.php Class Class source
  Plain text file Entity.php Class Class source
  Plain text file Exception.php Class Class source
  Plain text file Neon.php Class Class source

  Files folder image Files  /  SKien  
File Role Description
Files folder imageConfig (9 files)
Files folder imageTest (1 directory)

  Files folder image Files  /  SKien  /  Config  
File Role Description
  Plain text file AbstractConfig.php Class Class source
  Plain text file ArrayConfig.php Class Class source
  Plain text file ConfigInterface.php Class Class source
  Plain text file INIConfig.php Class Class source
  Plain text file JSONConfig.php Class Class source
  Plain text file NEONConfig.php Class Class source
  Plain text file NullConfig.php Class Class source
  Plain text file XMLConfig.php Class Class source
  Plain text file YAMLConfig.php Class Class source

  Files folder image Files  /  SKien  /  Test  
File Role Description
Files folder imageConfig (8 files, 1 directory)

  Files folder image Files  /  SKien  /  Test  /  Config  
File Role Description
Files folder imagetestdata (11 files)
  Plain text file AbstractConfigTest.php Class Class source
  Plain text file ArrayConfigTest.php Class Class source
  Plain text file INIConfigTest.php Class Class source
  Plain text file JSONConfigTest.php Class Class source
  Plain text file NEONConfigTest.php Class Class source
  Plain text file NullConfigTest.php Class Class source
  Plain text file XMLConfigTest.php Class Class source
  Plain text file YAMLConfigTest.php Class Class source

  Files folder image Files  /  SKien  /  Test  /  Config  /  testdata  
File Role Description
  Accessible without login Plain text file InvalidConfig.json Data Auxiliary data
  Accessible without login Plain text file InvalidConfig.neon Data Auxiliary data
  Accessible without login Plain text file InvalidConfig.xml Data Auxiliary data
  Accessible without login Plain text file InvalidConfig.yaml Data Auxiliary data
  Accessible without login Plain text file MergeExample1.json Data Auxiliary data
  Accessible without login Plain text file MergeExample2.json Data Auxiliary data
  Accessible without login Plain text file TestConfig.ini Data Auxiliary data
  Accessible without login Plain text file TestConfig.json Data Auxiliary data
  Accessible without login Plain text file TestConfig.neon Data Auxiliary data
  Accessible without login Plain text file TestConfig.xml Data Auxiliary data
  Accessible without login Plain text file TestConfig.yaml Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
 100%
Total:113
This week:0
All time:9,358
This week:181Up
For more information send a message to info at phpclasses dot org.