vakata/config

A PHP config class (parses .env files)

2.2.0 2023-12-21 12:47 UTC

This package is auto-updated.

Last update: 2024-10-21 14:36:14 UTC


README

Latest Version on Packagist Software License

A PHP config class, which supports parsing .env files.

Install

Via Composer

$ composer require vakata/config

Usage

$config = new \vakata\config\Config([ 'key' => 'value' ]);
$config->fromFile(__DIR__ . '/config.env');
$config->get('key'); // "value"
$config->set('key', 2); // 2
$config->get('key'); // 2
$config->del('key'); // true
$config->get('key'); // null
$config->get('key', 'default'); // "default"
$config->export(); // export all stored values to enviroment and $_SERVER
$config->export(true); // same as above but overwrite existing values

Testing

$ phpunit --bootstrap ./vendor/autoload.php ./tests/

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email github@vakata.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.