PHPackages                             boomdraw/laravel-dotenv - 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. boomdraw/laravel-dotenv

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

boomdraw/laravel-dotenv
=======================

Laravel dotenv manager

v2.1.0(5y ago)03.1kMITPHPPHP ^7.3|^8.0

Since Aug 3Pushed 5y ago1 watchersCompare

[ Source](https://github.com/boomdraw/laravel-dotenv)[ Packagist](https://packagist.org/packages/boomdraw/laravel-dotenv)[ RSS](/packages/boomdraw-laravel-dotenv/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (5)Dependencies (4)Versions (6)Used By (0)

Laravel Dotenv Manager
======================

[](#laravel-dotenv-manager)

The package that allows read and write `.env` file variables

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

[](#installation)

Via Composer

```
composer require boomdraw/laravel-dotenv
```

The package will automatically register itself.

You can publish the config file with:

```
php artisan vendor:publish --provider="Boomdraw\Dotenv\DotenvServiceProvider" --tag="config"
```

Usage and methods
-----------------

[](#usage-and-methods)

```
use Dotenv;
//or
use Boomdraw\Dotenv\Facades\Dotenv;
//or
use Boomdraw\Dotenv\Contracts\DotenvContract;

class Controller
{
    /**
     * @var \Boomdraw\Dotenv\Repositories\DotenvRepository
     */
    protected $dotenv;

    public function __construct(DotenvContract $dotenv)
    {
        $this->dotenv = $dotenv;
    }
}
```

### all

[](#all)

```
Dotenv::all(): Collection
```

The function returns all `.env` vars as an `\Illuminate\Support\Collection` object.

### set

[](#set)

```
Dotenv::set($key, ?string $value = null): self
```

The function writes the `.env` variable regardless of the variable existence.

```
Dotenv::setEmpty($key, ?string $value = null): self
```

The function writes the `.env` variable if it does not exist or empty.

### add

[](#add)

```
Dotenv::add($key, ?string $value = null): self
```

The function adds the `.env` variable if does not exist.

### put

[](#put)

```
Dotenv::put($key, ?string $value = null): self
```

The function updates `.env` variable if it exists.

```
Dotenv::putEmpty($key, ?string $value = null): self
```

The function updates `.env` variable if it exists and empty.

### delete

[](#delete)

```
Dotenv::delete($key): self
```

The function deletes `.env` variable.

An array of keys to delete can be passed as `$key` variable.

### Setters features

[](#setters-features)

You can pass data as an array for setters (`set`, `add`, `put`):

`Dotenv::set['key1' => 'value1', 'key2' => 'value2']`

Setters transform variable name removing quotes (`'`, `"`), replacing spaces (` `) and hyphens (`-`) with an underscore (`_`) and transforming name to uppercase.

For example `Dotenv::set('foo bar', 'baz')` will write `FOO_BAR=baz` to `.env` file.

All setters and `delete` will rewrite `.env` file immediately.

### reload

[](#reload)

```
Dotenv::reload(): self
```

The function reloads `.env` file from the filesystem.

### Collection methods

[](#collection-methods)

You can call all of [Collection](https://laravel.com/docs/5.8/collections) methods. For example:

`Dotenv::get('APP_NAME')` returns `APP_NAME` value.

`Dotenv::has('APP_NAME')` checks `APP_NAME` variable existence.

All collection methods are called for `Dotenv` collection copy, so any changes to collection will not affect `.env` file and `Dotenv` content.

Testing
-------

[](#testing)

You can run the tests with:

```
composer test
```

Security
--------

[](#security)

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

License
-------

[](#license)

[MIT](http://opensource.org/licenses/MIT)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity67

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

Total

5

Last Release

1914d ago

Major Versions

v1.1.0 → v2.0.02021-02-11

PHP version history (2 changes)v1.1.0PHP ^7.2

v2.0.0PHP ^7.3|^8.0

### Community

Maintainers

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

---

Top Contributors

[![boomdraw](https://avatars.githubusercontent.com/u/12460074?v=4)](https://github.com/boomdraw "boomdraw (5 commits)")

---

Tags

laravelenvdotenv

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/boomdraw-laravel-dotenv/health.svg)

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

###  Alternatives

[akaunting/laravel-money

Currency formatting and conversion package for Laravel

7825.3M18](/packages/akaunting-laravel-money)[msztorc/laravel-env

Laravel env helper commands

7855.4k](/packages/msztorc-laravel-env)[johannschopplich/kirby-helpers

Environment, SEO, and build utilities for Kirby CMS

277.4k](/packages/johannschopplich-kirby-helpers)

PHPackages © 2026

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