PHPackages                             codezero/dotenv-updater - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. codezero/dotenv-updater

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

codezero/dotenv-updater
=======================

Update key/value pairs in a .env file.

2.0.0(2y ago)5107.1k↓47%32MITPHPPHP ^7.3|^8.0CI failing

Since Dec 31Pushed 2y ago2 watchersCompare

[ Source](https://github.com/codezero-be/dotenv-updater)[ Packagist](https://packagist.org/packages/codezero/dotenv-updater)[ Fund](https://paypal.me/ivanvermeyen)[ Fund](https://ko-fi.com/ivanvermeyen)[ RSS](/packages/codezero-dotenv-updater/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (6)Dependencies (1)Versions (7)Used By (2)

PHP `.env` Updater
==================

[](#php-env-updater)

[![GitHub release](https://camo.githubusercontent.com/fba8c102c8de46c4feeaf586fa8a90cbeb2b0e3b970e9d2d9117982750e4a939/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f636f64657a65726f2d62652f646f74656e762d757064617465722e7376673f7374796c653d666c61742d737175617265)](https://github.com/codezero-be/dotenv-updater/releases)[![License](https://camo.githubusercontent.com/bd59a5b86f45b24cf33242586062d5ea0c4cbacebc3a3d5933ec50ded6afb388/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f636f64657a65726f2f646f74656e762d757064617465722e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/dad310129aacac0168b10a2266f0c52ffa66ddcf7e534f8805924bfd7fbf37e6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636f64657a65726f2d62652f646f74656e762d757064617465722f72756e2d74657374732e796d6c3f7374796c653d666c61742d737175617265266c6f676f3d676974687562266c6f676f436f6c6f723d7768697465266c6162656c3d7465737473)](https://github.com/codezero-be/dotenv-updater/actions)[![Code Quality](https://camo.githubusercontent.com/18b370406995daddec31dcdba558e78a94d9835543742587441222f0cfd6ea6c/68747470733a2f2f696d672e736869656c64732e696f2f636f646163792f67726164652f36623930343932363937623134353536393938363037646135353531303637362f6d61737465723f7374796c653d666c61742d737175617265)](https://app.codacy.com/gh/codezero-be/dotenv-updater)[![Total Downloads](https://camo.githubusercontent.com/d156e8ad59f78e16f3f5405920f2f4ede34eaf1e45d076c2a22274285272ad62/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f64657a65726f2f646f74656e762d757064617465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/codezero/dotenv-updater)

[![ko-fi](https://camo.githubusercontent.com/1fedf764fa06114b797ee53e7506df10880abed6766f854202d758df1707969d/68747470733a2f2f7777772e6b6f2d66692e636f6d2f696d672f676974687562627574746f6e5f736d2e737667)](https://ko-fi.com/R6R3UQ8V)

#### Update key/value pairs in a `.env` file.

[](#update-keyvalue-pairs-in-a-env-file)

✅ Requirements
--------------

[](#-requirements)

- PHP &gt;= 7.3

📦 Install
---------

[](#-install)

```
composer require codezero/dotenv-updater
```

🛠 Usage
-------

[](#-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
---------

[](#-testing)

```
composer test
```

☕️ Credits
----------

[](#️-credits)

- [Ivan Vermeyen](https://byterider.io)
- [All contributors](../../contributors)

🔓 Security
----------

[](#-security)

If you discover any security related issues, please [e-mail me](mailto:ivan@codezero.be) instead of using the issue tracker.

📑 Changelog
-----------

[](#-changelog)

A complete list of all notable changes to this package can be found on the [releases page](https://github.com/codezero-be/dotenv-updater/releases).

📜 License
---------

[](#-license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 92% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~309 days

Recently: every ~387 days

Total

6

Last Release

827d ago

Major Versions

1.2.0 → 2.0.02024-03-28

PHP version history (3 changes)1.0.0PHP ^7.1

1.1.2PHP ^7.1|^8.0

2.0.0PHP ^7.3|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/2e17b7a892452367dfb0e5c55bf04844a16bb781f356f50019332d4b9a476ec6?d=identicon)[codezero](/maintainers/codezero)

---

Top Contributors

[![ivanvermeyen](https://avatars.githubusercontent.com/u/3598622?v=4)](https://github.com/ivanvermeyen "ivanvermeyen (23 commits)")[![Pezhvak](https://avatars.githubusercontent.com/u/3134479?v=4)](https://github.com/Pezhvak "Pezhvak (1 commits)")[![totoprayogo1916](https://avatars.githubusercontent.com/u/2387514?v=4)](https://github.com/totoprayogo1916 "totoprayogo1916 (1 commits)")

---

Tags

dotenveditorenvphpupdaterphpenvdotenveditorupdater

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/codezero-dotenv-updater/health.svg)

```
[![Health](https://phpackages.com/badges/codezero-dotenv-updater/health.svg)](https://phpackages.com/packages/codezero-dotenv-updater)
```

###  Alternatives

[vlucas/phpdotenv

Loads environment variables from `.env` to `getenv()`, `$\_ENV` and `$\_SERVER` automagically.

13.5k640.2M6.3k](/packages/vlucas-phpdotenv)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
