PHP code example of emargareten / config-php

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

    

emargareten / config-php example snippets




return [
    'key' => 'value',
    'another_key' => 'another_value',
];

Config::setPath('/path/to/config.php');

$config = new Config('/path/to/config.php');

Config::setValues([
    'key' => 'value',
    'another_key' => 'another_value',
]);


// Get a value from your configuration
$value = Config::get('key');

// Get a value with a default value if key is not found
$value = Config::get('key', 'default');

// Set a value in your configuration
Config::set('key', 'value');

// Remove a value from your configuration
Config::forget('key');

// Remove all values from your configuration
Config::clear();

// Set multiple values in your configuration
Config::setMany([
    'key1' => 'value1',
    'key2' => 'value2',
]);

// Reset your configuration to its initial state (rereads the config file)
Config::reset();

// Check if a key exists in your configuration
if (Config::has('key')) {
    // ...
}

// Get all values from your configuration
$values = Config::all();

config()->get('key'); // or config('key')

config()->set('key', 'value');

// ...