codezero/dotenv-updater

Update key/value pairs in a .env file.

1.1.2 2020-12-28 09:45 UTC

This package is auto-updated.

Last update: 2021-11-28 12:02:33 UTC


README

GitHub release License Build Status Code Coverage Scrutinizer Code Quality Total Downloads

ko-fi

Update key/value pairs in a .env file.

✅ Requirements

  • PHP >= 7.1

📦 Install

composer require codezero/dotenv-updater

🛠 Usage

Create an instance of the DotEnvUpdater and pass it the path to the .env file:

$updater = new \CodeZero\DotEnvUpdater\DotEnvUpdater('/path/to/.env');

Add any new, or overwrite any existing key/value pairs:

$updater->set('MY_ENV_KEY', 'Some Value'); // Strings
$updater->set('MY_ENV_KEY', 25); // Integers
$updater->set('MY_ENV_KEY', true); // Booleans
$updater->set('MY_ENV_KEY', null); // NULL values
$updater->set('MY_ENV_KEY', ''); // Empty values

Retrieve the value of a key:

$value = $updater->get('MY_ENV_KEY');

🚧 Testing

composer test

☕️ Credits

🔓 Security

If you discover any security related issues, please e-mail me instead of using the issue tracker.

📑 Changelog

See a list of important changes in the changelog.

📜 License

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