Single and multi-dimensional parameter bag.
composer require initphp/parameterbag
- PHP 7.2 or later
require_once "vendor/autoload.php";
use \InitPHP\ParameterBag\ParameterBag;
$parameter = new ParameterBag($_GET);
// GET /?user=muhametsafak
echo $parameter->get('user', null); // "muhametsafak"
require_once "vendor/autoload.php";
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;
Copyright © 2022 - MIT License