PHPackages                             nathanlesage/envedit - 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. nathanlesage/envedit

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

nathanlesage/envedit
====================

A simple class for editing the .env-file in your project via PHP.

v0.1.2(9y ago)134MITPHPPHP &gt;=5.3.0

Since Sep 17Pushed 9y ago1 watchersCompare

[ Source](https://github.com/nathanlesage/envedit)[ Packagist](https://packagist.org/packages/nathanlesage/envedit)[ RSS](/packages/nathanlesage-envedit/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (3)DependenciesVersions (4)Used By (0)

EnvEdit
=======

[](#envedit)

A simple class for editing the .env-file in your project via PHP.

Why edit your .env-file via PHP?
--------------------------------

[](#why-edit-your-env-file-via-php)

Normally, the .env-file is used by developers to adapt to the current environment like production, develop, local, etc. To adapt to these environments, it is necessary to store different credentials (like database username and password, etc.) for different environments.

But if you are developing an app that relies on an .env-file and should be distributed to end users, you cannot assume they know which values for an .env-file are correct and which are not. Also, you might not want your end users to always ssh to your server to edit the file, but do it with a comfortable GUI. So this library enables you to easily read an .env-file, edit the values and re-write the file with the new variables.

Installation
------------

[](#installation)

You can install it easily via composer:

```
$ composer require nathanlesage/envedit
```

Usage
-----

[](#usage)

You only need to interact with the `EnvEdit` class. You may access your .env-file by passing its path to a new `EnvEdit` object:

```
use NathanLeSage\EnvEdit;

...

$editor = new EnvEdit('/path/to/your/.env');

// Read and parse the file

$editor->read();

// Retrieve the value of a specific variable.
// Of course, you should normally do this via env('APP_ENVIRONMENT')
// or similar.

$value = $editor->getValue('APP_ENVIRONMENT');

// Change one or more variables

$editor->setVars(
    ['APP_ENVIRONMENT' => 'production',
    'REDIS_HOST' => '123.321.12.32']
    );

// Write your changes to file

$editor->write();

// You could also retrieve the file's contents without writing them.
// This is useful for backup purposes or letting the user control what
// will be altered.

$editor->getFile();
```

Contribution
------------

[](#contribution)

If you would like to contribute, just fork this library and send a pull request with your changes! I appreciate every help!

License
-------

[](#license)

This library is licensed under the terms of the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~130 days

Total

3

Last Release

3313d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d0d70e78d15f22d297f8d69d81d0c87931a35b8d032fbc67b1e8a670784e6d7e?d=identicon)[nathanlesage](/maintainers/nathanlesage)

---

Top Contributors

[![nathanlesage](https://avatars.githubusercontent.com/u/17251683?v=4)](https://github.com/nathanlesage "nathanlesage (3 commits)")

### Embed Badge

![Health badge](/badges/nathanlesage-envedit/health.svg)

```
[![Health](https://phpackages.com/badges/nathanlesage-envedit/health.svg)](https://phpackages.com/packages/nathanlesage-envedit)
```

###  Alternatives

[ghunti/highcharts-php

A php wrapper for highcharts and highstock javascript libraries

3632.3M5](/packages/ghunti-highcharts-php)[apy/datagrid-bundle

Symfony Datagrid Bundle

4921.0M9](/packages/apy-datagrid-bundle)[pithyone/wechat

企业微信SDK

1032.4k1](/packages/pithyone-wechat)[spryker/decimal

PHP decimal handling as value object

231.6k](/packages/spryker-decimal)

PHPackages © 2026

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