1. Go to this page and download the library: Download fluix/fconfig 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/ */
fluix / fconfig example snippets
cret is a random string with length of 16 characters, which is used for encrypting/decrypting your secure configuration.
// Example of generating secret via openssl: openssl rand -hex 8
$secret = "ff7f8dc665734d9d"; // don't use this secret in your application, generate a new one and store it in a safe place.
$config = \Fluix\Config\Factory::config(
$secret,
null,
"postProcessor"
);
$pathToConfig = __DIR__ . "/config/config.json";
$configFolder = __DIR__ . "/config/_generated";
$config->dump(
\Fluix\Config\Template::fromPath($pathToConfig),
$const = \Fluix\Config\Dump\Destination::create($configFolder, \Fluix\Config\Dump\Format::const()),
$yaml = \Fluix\Config\Dump\Destination::create($configFolder, \Fluix\Config\Dump\Format::yaml()),
$array = \Fluix\Config\Dump\Destination::create($configFolder, \Fluix\Config\Dump\Format::php()),
$json = \Fluix\Config\Dump\Destination::create($configFolder, \Fluix\Config\Dump\Format::json())
);
echo "Config has been successfully dumped to {$const}" . PHP_EOL;
echo "Config has been successfully dumped to {$yaml}" . PHP_EOL;
echo "Config has been successfully dumped to {$array}" . PHP_EOL;
echo "Config has been successfully dumped to {$json}" . PHP_EOL;
function postProcessor(\Fluix\Config\ParserResult $result)
{
// extra actions could be performed here
// e.g. nginx.conf could be generated withing the parsed data
}
cret is a random string with length of 16 characters, which is used for encrypting/decrypting your secure configuration.
// Example of generating secret via openssl: openssl rand -hex 8
$secret = "ff7f8dc665734d9d"; // don't use this secret in your application, generate a new one and store it in a safe place.
$pathToFallbackFile = __DIR__ . "/fallback.json";
$pathToConfig = __DIR__ . "/config/config.json";
$configFolder = __DIR__ . "/config/_generated";
$config = \Fluix\Config\Factory::config(
$secret,
Fluix\Config\File::fromPath($pathToFallbackFile),
"postProcessor"
);
$config->dump(
\Fluix\Config\Template::fromPath($pathToConfig),
$const = \Fluix\Config\Dump\Destination::create($configFolder, \Fluix\Config\Dump\Format::const()),
$yaml = \Fluix\Config\Dump\Destination::create($configFolder, \Fluix\Config\Dump\Format::yaml()),
$array = \Fluix\Config\Dump\Destination::create($configFolder, \Fluix\Config\Dump\Format::php()),
$json = \Fluix\Config\Dump\Destination::create($configFolder, \Fluix\Config\Dump\Format::json())
);
function postProcessor(\Fluix\Config\ParserResult $result)
{
// extra actions could be performed here
// e.g. nginx.conf could be generated withing the parsed data
}