PHP code example of rollylni / liteconfig

1. Go to this page and download the library: Download rollylni/liteconfig 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/ */

    

rollylni / liteconfig example snippets




$cfg = new LiteConfig\Config("File.json"); //detect format by extension
$cfg->load([
    "default_formats" => ["yaml", "json", "ini", "enum", "serialize"],
    "default_key" => "default_value"
]);
$cfg->set("key", "value");
$cfg->save();



use LiteConfig\Format\Format;
use LiteConfig\Config;

class MyFormat extends Format {

    public function getName() {
        return "My own Format";
    }
    
    public function read(string $input): array {
         return json_decode(base64_decode($input));
    }
    
    public function write(array $input): string {
        return base64_encode(json_encode($input));
    }
}
$format = new MyFormat("json64");
$format->addAlias("js64");
Config::addFormat($format);