1. Go to this page and download the library: Download navindex/simple-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/ */
navindex / simple-config example snippets
use BaliNomad\SimpleConfig\Config;
$options = [
'allowed_pets' => ['dog', 'cat', 'spider'],
'cat' => [
'name' => 'Mia',
'food' => ['tuna', 'chicken', 'lamb'],
],
'dog' => [
'name' => 'Bless',
'color' => [
'body' => 'white',
'tail' => 'black',
]
],
'has_spider' => true
];
$config = new Config($options);
// with(), without(), etc. return a NEW Config instance.
$newConfig = $config
->with('has_spider', false) // Set a value
->without('dog.color.tail') // Remove a value
->append('cat.food', 'salmon') // Add an item to an array
->subtract('allowed_pets', 'spider'); // Remove an item from an array
// Get values using dot notation
$catFood = $newConfig->get('cat.food');
// Returns: ['tuna', 'chicken', 'lamb', 'salmon']
// Check if a key exists
$hasTailColor = $newConfig->has('dog.color.tail');
// Returns: false
// The original $config object remains unchanged
$originalSpiderSetting = $config->get('has_spider');
// Returns: true
// Get the entire configuration as an array
$arrConfig = $newConfig->toArray();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.