PHPackages                             moh-slimani/laravel-env-write - 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. moh-slimani/laravel-env-write

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

moh-slimani/laravel-env-write
=============================

A package to write to the .env file.

0.0.1(2y ago)120[2 PRs](https://github.com/moh-slimani/laravel-env-write/pulls)MITPHPPHP ^8.2

Since Feb 29Pushed 1y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (13)Versions (4)Used By (0)

A package to write to the .env file.
====================================

[](#a-package-to-write-to-the-env-file)

[![Latest Version on Packagist](https://camo.githubusercontent.com/7726134e5d60e086465a2be834cfa19591b1a26abc5ce3a635e61f52e24e91d8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6f682d736c696d616e692f6c61726176656c2d656e762d77726974652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/moh-slimani/laravel-env-write)[![GitHub Tests Action Status](https://camo.githubusercontent.com/f8ceddf8535b9fca667a4fb5ae39e0989c9c9207c2a35136d0f3057703489173/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d6f682d736c696d616e692f6c61726176656c2d656e762d77726974652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/moh-slimani/laravel-env-write/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/71afc8c9c28c5a7b46389cae360df1ff5162629a4d8c684b3f666a3fb682ced6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d6f682d736c696d616e692f6c61726176656c2d656e762d77726974652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/moh-slimani/laravel-env-write/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/4b8c134bf03478db7ecbe12f246dba38df43e9792fc4abbd1992c8851d72cebe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6f682d736c696d616e692f6c61726176656c2d656e762d77726974652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/moh-slimani/laravel-env-write)

LaravelEnvWrite is a Laravel package designed to simplify the process of updating the .env file in Laravel applications. It provides a convenient way to automatically update the environment file during database seeding or from anywhere in the codebase.

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/6337f95e9084de2d863a7f4a55a0e4abfa8a4a0ecc472663d8ec699c90ba1f2a/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d656e762d77726974652e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-env-write)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

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

[](#installation)

You can install the package via composer:

```
composer require moh-slimani/laravel-env-write
```

Configuration
-------------

[](#configuration)

The package doesn't require any additional configuration. Once installed, you can start using it immediately.

Usage
-----

[](#usage)

### Command Line Interface

[](#command-line-interface)

The package provides an Artisan command to update the .env file from the command line.

```
php artisan env:write {key} {value?}
```

- {key}: The key to update in the .env file. It can be provided either as a single argument or in the format key=value.
- {value}: The value to set for the key. This argument is optional and only required when providing a single argument for the key.

#### Examples

[](#examples)

```
php artisan env:write APP_ENV production
```

```
php artisan env:write APP_KEY=your_app_key
```

### Programmatically

[](#programmatically)

You can also use the package programmatically in your codebase:

```
use MohSlimani\LaravelEnvWrite\Facades\LaravelEnvWrite;

// Update the environment file with a specific key and value
LaravelEnvWrite::updateEnvironmentFileWith('APP_ENV', 'production');
```

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)

- [Mohamed slimani](https://github.com/moh-slimani)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 71.4% 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

Unknown

Total

1

Last Release

803d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/889517e68d00e2c3709f76b1b944493e4303ff205c6a836108fb8dae6eb50cb6?d=identicon)[slimani](/maintainers/slimani)

---

Top Contributors

[![slimani-dev](https://avatars.githubusercontent.com/u/25089144?v=4)](https://github.com/slimani-dev "slimani-dev (5 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

laravelMohamed slimanilaravel-env-write

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/moh-slimani-laravel-env-write/health.svg)

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

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

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