PHP code example of nikoutel / helionconfig
1. Go to this page and download the library: Download nikoutel/helionconfig library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nikoutel / helionconfig example snippets
$helionConfig = new HelionConfig();
$configReader = $helionConfig->getConfigReader(ConfigType::XML, $options);
$configSrc = 'file.xml';
$config = $configReader->getConfig($configSrc);
$value = $configReader->getConfigValue($key, $config);
$configAsArray = $config->asArray();
$configAsArrayFlat = $config->asArrayFlat();
$options = array(
'sectionSeparator' => ':',
'rootName' => 'myConf',
'libxmlOptions' => array(
LIBXML_PARSEHUGE, LIBXML_NOBLANKS
),
'jsonOptions' => array(
JSON_PRETTY_PRINT, JSON_NUMERIC_CHECK
),
'curlOptions' => array(
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_USERPWD => 'AzureDiamond:hunter2'
),
'genericConf' => array(
'sectionStart' => "[",
'sectionEnd' => "]",
'equals' => "=",
'multiLineSeparator' => "\\",
'commentStart' => "#",
)
);
use Nikoutel\HelionConfig\HelionConfig;
use Nikoutel\HelionConfig\ConfigType\ConfigType;
$configSrc = 'db.ini';
$helionConfig = new HelionConfig();
$configReader = $helionConfig->getConfigReader(ConfigType::INI, $options);
$config = $configReader->getConfig($configSrc);
$port = $configReader->getConfigValue('database.port', $config);
$port = $configReader->getConfigValue('database.port', $config);
$configSrc = '{ "isbn": "0-13-110362-8",
"author": [
{"firstname": "Brian", "lastname": "Kernighan"},
{"firstname": "Dennies", "lastname": "Ritchie"}],
"title": "The C Programming Language",
"category": ["Programming", "Technology"]}';
$helionConfig = new HelionConfig();
$configReader = $helionConfig->getConfigReader(ConfigType::JSON, $options);
$array = $configReader->getConfig($configSrc)->asArrayFlat();
$options = array(
'genericConf' => array(
'commentStart' => "#",
)
);
$helionConfig = new HelionConfig();
$configReader = $helionConfig->getConfigReader(ConfigType::CONF, $options);
$config = $configReader->getConfig('/etc/mysql/my.cnf');
// get only the 'mysqld' section
$mysqldCofigSection = $configReader->getConfigValue('mysqld', $config);
// get the 'port' from the 'mysqld' section
$port = $configReader->getConfigValue('port', $mysqldCofigSection);
$helionConfig = new HelionConfig();
$configReader = $helionConfig->getConfigReader(ConfigType::APACHE);
$config = $configReader->getConfig($configSrc);
$array = $config->asArray();
$arrayFlat = $config->asArrayFlat()