Download the PHP package nikoutel/helionconfig without Composer
On this page you can find all versions of the php package nikoutel/helionconfig. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nikoutel/helionconfig
More information about nikoutel/helionconfig
Files in nikoutel/helionconfig
Package helionconfig
Short Description A versatile configuration parser. Can handle multiple configuration formats.
License MPL-2.0
Informations about the package helionconfig
HelionConfig
A versatile configuration parser. Can handle multiple configuration formats.
HelionConfig is a tool for reading (and soon, writing) different configuration types (INI, XML, JSON, apache, PHP arrays, generic conf), returning the whole configuration, a section, or a specific value.
Usage
Parameters
ConfigType
A ConfigType
parameter.
Available types are:
ConfigType::INI
ConfigType::XML
ConfigType::JSON
ConfigType::PHPARRAY
(configuration stored in a php array) *ConfigType::APACHE
(apache2.conf
/httpd.conf
type configuration)ConfigType::CONF
(configurable generic configuration type, see options and examples)
* The PHPArray file should only include an array with the configuration data, and a return
statement returning the array.
Method $helionConfig->listConfigTypes()
returns all available config types.
configSrc
The configuration source could be a file path, URL, or a configuration string.
options (optional)
An options array can be passed to the getConfigReader
method of HelionConfig
.
Array elements:
rootName
: name of the root object element - Default:configRoot
sectionSeparator
: symbol used to denote the separation of subsections and value - Default:.
libxmlOptions
: used to specify optional libxml parameters - e.g.:LIBXML_PARSEHUGE, LIBXML_NOBLANKS
jsonOptions
: used to specify optional json constants - e.g.:JSON_PRETTY_PRINT, JSON_NUMERIC_CHECK
curlOptions
: an array specifying additional curlopt constants - e.g.:CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_USERPWD => 'AzureDiamond:hunter2'
genericConf
: used to specify the symbols for the configurable generic configuration format - Default:'sectionStart' => "["
'sectionEnd' => "]"
'equals' => "="
'multiLineSeparator' => "\\"
'commentStart' => ";"
Options Example:
Return values
HelionConfig returns a HelionConfigValue
Object representing configuration data.
All data are enclosed in a root object element named configRoot
(can be changed through the options array).
Each directive and each section, is represented by an HelionConfigValue
Object, and multiple subsections and values, are grouped in arrays of HelionConfigValue
Objects.
Specific values or subsections can be returned with the getConfigValue()
method, of the HelionConfigValue
Object.
Nested sections can be accessed by chaining the subsections with the sectionSeparator
options array element
(default is .
) (e.g.: section1.section2.key
)
To convert a HelionConfigValue
Object to an array, the method asArray()
is provided.
Additionally the method asArrayFlat()
returns a flat Array.
Sections and value are separated with sectionSeparator
.
Requirements
- PHP 7 (min)
- SimpleXML php extension
- libxml php extension
- JavaScript Object Notation php extension (json)
- Client URL Library Object Notation php extension (curl)
Install
composer:
Examples
Example #1 (simple .ini file):
will output:
and:
will output:
Example #2 (config-like json passed as a string):
will output:
Example #3 (configurable generic configuration type):
MySQL uses INI type configuration files but with comments marked with the non-standard ‘#’
will output:
and:
will output:
Example #4 (apache vhost conf):
will output:
Todo
- YAML
- TOML
- Add writing/editing capabilities (getConfigWriter())
- Combine sources
License
This software is licensed under the MPL 2.0:
All versions of helionconfig with dependencies
ext-simplexml Version *
ext-libxml Version *
ext-json Version *