PHPackages                             amdadulhaq/env-editor-laravel - 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. amdadulhaq/env-editor-laravel

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

amdadulhaq/env-editor-laravel
=============================

ENV Editor for laravel

v2.0.0(4mo ago)1278MITPHPPHP ^8.2|^8.3|^8.4|^8.5CI passing

Since Dec 10Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/amdad121/env-editor-laravel)[ Packagist](https://packagist.org/packages/amdadulhaq/env-editor-laravel)[ Docs](https://github.com/amdad121/env-editor-laravel)[ GitHub Sponsors](https://github.com/amdad121)[ RSS](/packages/amdadulhaq-env-editor-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (7)Versions (7)Used By (0)

ENV Editor for Laravel
======================

[](#env-editor-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/32db76892d20699138d1cceb2d2980034494db8392a8e8511d3aef8d2a5bd3e3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616d646164756c6861712f656e762d656469746f722d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/amdadulhaq/env-editor-laravel)[![GitHub Tests Action Status](https://camo.githubusercontent.com/135c0f1f921cf35637e83a318dbcccb64fee524e0a0bc35fbf92cd8f587a7fc5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616d6461643132312f656e762d656469746f722d6c61726176656c2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/amdad121/env-editor-laravel/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/337e9c50d322cce097411de40af95397504762ca9cfcd19790a753d306beb444/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616d6461643132312f656e762d656469746f722d6c61726176656c2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/amdad121/env-editor-laravel/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/c5ad60d25e4aff9b2536fe4f3e8fc3b4aa97f0b5624b46724c65d6f223d3dbc6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616d646164756c6861712f656e762d656469746f722d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/amdadulhaq/env-editor-laravel)

Simple and powerful ENV file editor for your Laravel application.

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

[](#installation)

You can install the package via composer:

```
composer require amdadulhaq/env-editor-laravel
```

Usage
-----

[](#usage)

### Basic Methods

[](#basic-methods)

```
use AmdadulHaq\EnvEditor\EnvEditor;

// Set a new key or update an existing one
EnvEditor::set('APP_NAME', 'MyApp');

// Update an existing key (throws exception if key doesn't exist)
EnvEditor::update('APP_NAME', 'MyApp');

// Set or update (smart - checks if key exists)
EnvEditor::setOrUpdate('APP_NAME', 'MyApp');

// Remove a key
EnvEditor::remove('APP_NAME');
```

### Reading Values

[](#reading-values)

```
// Get a single value
$appName = EnvEditor::get('APP_NAME');
$appName = EnvEditor::get('NON_EXISTENT_KEY', 'default_value'); // with default

// Get all values as an array
$allEnv = EnvEditor::getAll();

// Check if a key exists
$hasKey = EnvEditor::has('APP_NAME');
```

### Backup and Restore

[](#backup-and-restore)

```
// Create a backup (auto-generates timestamp-based filename)
$backupPath = EnvEditor::backup();

// Create a backup with custom name
$backupPath = EnvEditor::backup('backup-before-deployment.env');

// List all available backups
$backups = EnvEditor::listBackups();

// Restore from a backup
EnvEditor::restore('backup-before-deployment.env');
```

### Using with Dependency Injection

[](#using-with-dependency-injection)

```
use AmdadulHaq\EnvEditor\EnvEditor;

class SomeService
{
    public function __construct(
        protected EnvEditor $envEditor
    ) {}

    public function updateSettings()
    {
        $this->envEditor->set('SOME_KEY', 'value');
        $value = $this->envEditor->get('SOME_KEY');
    }
}
```

### Custom ENV File Path

[](#custom-env-file-path)

If you need to work with a different .env file:

```
$editor = new EnvEditor('/path/to/custom/.env');
$editor->set('KEY', 'value');
```

Features
--------

[](#features)

- ✅ Read, write, and update .env file values
- ✅ Check if keys exist
- ✅ Get all environment variables as an array
- ✅ Backup and restore .env files
- ✅ Handle values with spaces, quotes, and special characters
- ✅ Dependency injection support
- ✅ Custom .env file path support
- ✅ Comprehensive error handling
- ✅ Full test coverage with Pest

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Amdadul Haq](https://github.com/amdad121)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

45

—

FairBetter than 92% of packages

Maintenance84

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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 ~150 days

Total

6

Last Release

131d ago

Major Versions

v1.2.1 → v2.0.02026-01-02

PHP version history (2 changes)v1.0.0PHP ^8.1

v2.0.0PHP ^8.2|^8.3|^8.4|^8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/7219b32db58e53dddb8a970aec40c9a41ec7d6dbf3570fd89ac14abe7424532e?d=identicon)[amdadulhaq](/maintainers/amdadulhaq)

---

Top Contributors

[![amdad121](https://avatars.githubusercontent.com/u/11732880?v=4)](https://github.com/amdad121 "amdad121 (21 commits)")

---

Tags

editorenvenvironmentlaravellaravelAmdadul Haqenv-editor-laravel

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/amdadulhaq-env-editor-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/amdadulhaq-env-editor-laravel/health.svg)](https://phpackages.com/packages/amdadulhaq-env-editor-laravel)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[nedwors/navigator

A Laravel package to ease defining navigation menus

433.1k](/packages/nedwors-navigator)[xefi/faker-php-laravel

Faker php integration with laravel

1915.1k](/packages/xefi-faker-php-laravel)[dcblogdev/laravel-junie

Install pre-configured guides for Jetbrains Junie

392.5k](/packages/dcblogdev-laravel-junie)

PHPackages © 2026

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