PHPackages                             rdp77/laravel-env-set-command - 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. rdp77/laravel-env-set-command

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

rdp77/laravel-env-set-command
=============================

Set a .env file variable from the command line

1.4.0(3y ago)12301[1 issues](https://github.com/rdp77/laravel-env-set-command/issues)[1 PRs](https://github.com/rdp77/laravel-env-set-command/pulls)1MITPHPPHP ^7.3|^8.0

Since Oct 12Pushed 3y agoCompare

[ Source](https://github.com/rdp77/laravel-env-set-command)[ Packagist](https://packagist.org/packages/rdp77/laravel-env-set-command)[ Docs](https://github.com/rdp77/laravel-env-set-command)[ Fund](https://www.paypal.me/RaviDwiPutra77)[ GitHub Sponsors](https://github.com/imliam)[ RSS](/packages/rdp77-laravel-env-set-command/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (2)Dependencies (4)Versions (3)Used By (1)

Laravel `env:set` Command
=========================

[](#laravel-envset-command)

[![Latest Version on Packagist](https://camo.githubusercontent.com/20e60e017dceaf9bd320ff6271ceedb535ec1102fecf1f26f9b1e884df858070/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72647037372f6c61726176656c2d656e762d7365742d636f6d6d616e642e737667)](https://packagist.org/packages/rdp77/laravel-env-set-command)[![Total Downloads](https://camo.githubusercontent.com/a6add8784b565f5cb999c6f8e6bdeb0beb1474c7afa18dd48846182ccb0f25eb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72647037372f6c61726176656c2d656e762d7365742d636f6d6d616e642e737667)](https://packagist.org/packages/rdp77/laravel-env-set-command)[![License](https://camo.githubusercontent.com/af41088afac2b86c4cf5007774fd3a2f05a4f71629b095d1997c8d44a1eafcdb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f72647037372f6c61726176656c2d656e762d7365742d636f6d6d616e642e737667)](LICENSE.md)[![CI Status](https://github.com/rdp77/laravel-env-set-command/workflows/Run%20Tests/badge.svg)](https://github.com/rdp77/laravel-env-set-command/actions)

Set a .env file variable from the command line.

[![Example command output](./screenshot.png)](./screenshot.png)

- [Laravel `env:set` Command](#laravel-setenv-command)
    - [Installation](#installation)
    - [Usage](#usage)
    - [Changelog](#changelog)
    - [Contributing](#contributing)
        - [Security](#security)
    - [Credits](#credits)
    - [License](#license)

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

[](#installation)

You can install the package with [Composer](https://getcomposer.org/) using the following command:

```
composer require rdp77/laravel-env-set-command:^1.4.0
```

Usage
-----

[](#usage)

When running the `env:set` artisan command, you must provide both a key and value as two arguments.

```
$ php artisan env:set app_name Example
# Environment variable with key 'APP_NAME' has been changed from 'Laravel' to 'Example'
```

You can also set values with spaces by wrapping them in quotes.

```
$ php artisan env:set app_name "Example App"
# Environment variable with key 'APP_NAME' has been changed from 'Laravel' to '"Example App"'
```

The command will also create new environment variables if an existing one does not exist.

```
$ php artisan env:set editor=vscode
# A new environment variable with key 'EDITOR' has been set to 'vscode'
```

Instead of two arguments split by a space, you can also mimic the `.env` file format by supplying `KEY=VALUE`.

```
$ php artisan env:set app_name=Example
# Environment variable with key 'APP_NAME' has been changed from 'Laravel' to 'Example'
```

The command will do its best to stop any invalid inputs.

```
$ php artisan env:set @pp_n@me Laravel
# Invalid environment key @pp_n@me! Only use letters and underscores
```

You can specify the external `.env` file in the third optional argument.

```
$ php artisan env:set APP_NAME TestApp /var/www/my_own_env.env
# Environment variable with key 'APP_NAME' has been changed from 'Laravel' to 'TestApp'
```

Or in the second parameter if you use key=value syntax.

```
$ php artisan env:set APP_NAME=TestApp /var/www/my_own_env.env
# Environment variable with key 'APP_NAME' has been changed from 'Laravel' to 'TestApp'
```

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

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Moh Ravi Dwi Putra](https://github.com/rdp77)
- [Liam Hammett](https://github.com/imliam)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

22

↓

LowBetter than 23% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

Total

2

Last Release

1304d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/53ede82e9fa505873f08894c27c199db40e7dc54bfb0991977a82098c7dd36c0?d=identicon)[rdp77](/maintainers/rdp77)

---

Top Contributors

[![imliam](https://avatars.githubusercontent.com/u/4326337?v=4)](https://github.com/imliam "imliam (18 commits)")[![rdp77](https://avatars.githubusercontent.com/u/25810647?v=4)](https://github.com/rdp77 "rdp77 (14 commits)")[![CaliforniaMountainSnake](https://avatars.githubusercontent.com/u/44233829?v=4)](https://github.com/CaliforniaMountainSnake "CaliforniaMountainSnake (9 commits)")[![jameslkingsley](https://avatars.githubusercontent.com/u/11015784?v=4)](https://github.com/jameslkingsley "jameslkingsley (3 commits)")[![ddavaham](https://avatars.githubusercontent.com/u/7141998?v=4)](https://github.com/ddavaham "ddavaham (2 commits)")[![chapeupreto](https://avatars.githubusercontent.com/u/834048?v=4)](https://github.com/chapeupreto "chapeupreto (2 commits)")[![davidsneal](https://avatars.githubusercontent.com/u/6142131?v=4)](https://github.com/davidsneal "davidsneal (1 commits)")[![Cannonb4ll](https://avatars.githubusercontent.com/u/3110750?v=4)](https://github.com/Cannonb4ll "Cannonb4ll (1 commits)")

---

Tags

artisanenvironmentenvironment-variableslaravelphpregexartisanenvironmentregexenvvariableslaravel-env-set-commandrdp77

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rdp77-laravel-env-set-command/health.svg)

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

###  Alternatives

[vlucas/phpdotenv

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

13.5k602.4M5.4k](/packages/vlucas-phpdotenv)[imliam/laravel-env-set-command

Set a .env file variable from the command line

118352.4k10](/packages/imliam-laravel-env-set-command)[msztorc/laravel-env

Laravel env helper commands

7855.4k](/packages/msztorc-laravel-env)[cekurte/environment

A library to get the values from environment variables and process to php data types

5884.0k7](/packages/cekurte-environment)[mirazmac/dotenvwriter

A PHP library to write values to .env (DotEnv) files

19129.3k7](/packages/mirazmac-dotenvwriter)[tamer-dev/laravel-env-cli

laravel commands to work with .env file in cli

126.5k](/packages/tamer-dev-laravel-env-cli)

PHPackages © 2026

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