PHP code example of initphp / parameterbag

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

    

initphp / parameterbag example snippets



use \InitPHP\ParameterBag\ParameterBag;

$parameter = new ParameterBag($_GET);

// GET /?user=muhametsafak
echo $parameter->get('user', null); // "muhametsafak"


use \InitPHP\ParameterBag\ParameterBag;

$data = [
    'database'  => [
        'dsn'           => 'mysql:host=localhost',
        'username'      => 'root',
        'password'      => '123456'
    ]
];

$parameter = new ParameterBag($data, ['isMulti' => true, 'separator' => '.']);

$parameter->get('database.username'); // "root" 
$parameter->has('database.charset'); // false

public function has(string $key): bool;

public function get(string $key, mixed $default = null): mixed;

public function set(string $key, mixed $value): \InitPHP\ParameterBag\ParameterBagInterface;

public function remove(string ...$keys): \InitPHP\ParameterBag\ParameterBagInterface;

public function all(): array;

public function merge(array|\InitPHP\ParameterBag\ParameterBagInterface ...$merge): \InitPHP\ParameterBag\ParameterBagInterface;