PHP code example of hackphp / config
1. Go to this page and download the library: Download hackphp/config 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/ */
hackphp / config example snippets
use Hackphp\Config\Config;
use Hackphp\Config\Parsers\ArrayParser;
$config = new Config([
"app" => [
"name" => "HackPHP"
],
"server" => [
"host" => "127.0.0.1",
"port" => 8000
],
]);
$configRootDir = __DIR__ . "/config";
$config->addParser(new ArrayParser($configRootDir));
$config->load();
echo $config->get("server.host");
// output: 127.0.0.1
echo $config->get("file.key", "default value");
// output: default value