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

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

grantholle/laravel-dotenv-editor
================================

The .env file editor tool for Laravel 6+

1.0.8(7y ago)02.2kMITPHPPHP &gt;=5.4.0

Since May 15Pushed 5y ago1 watchersCompare

[ Source](https://github.com/grantholle/laravel-dotenv-editor)[ Packagist](https://packagist.org/packages/grantholle/laravel-dotenv-editor)[ RSS](/packages/grantholle-laravel-dotenv-editor/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (11)Used By (0)

Laravel Dotenv Editor
=====================

[](#laravel-dotenv-editor)

[![laravel-dotenv-editor](https://cloud.githubusercontent.com/assets/9862115/25982836/029612b2-370a-11e7-82c5-d9146dc914a1.png)](https://cloud.githubusercontent.com/assets/9862115/25982836/029612b2-370a-11e7-82c5-d9146dc914a1.png)

[![Latest Stable Version](https://camo.githubusercontent.com/a557d182ebab1601552abc23c5c2befbb0fc8ea2ebde3173308a7f80faaf7916/68747470733a2f2f706f7365722e707567782e6f72672f6a61636b6965646f2f646f74656e762d656469746f722f762f737461626c65)](https://packagist.org/packages/jackiedo/dotenv-editor)[![Total Downloads](https://camo.githubusercontent.com/4824d6be3c6b5e1a576a505952a3310168534f2e7c3ea8d9297f8ecb6bc88a83/68747470733a2f2f706f7365722e707567782e6f72672f6a61636b6965646f2f646f74656e762d656469746f722f646f776e6c6f616473)](https://packagist.org/packages/jackiedo/dotenv-editor)[![Latest Unstable Version](https://camo.githubusercontent.com/18c67cc473fb232493af158b1e4d89963bf4d148d764db4960c825c89b3177e0/68747470733a2f2f706f7365722e707567782e6f72672f6a61636b6965646f2f646f74656e762d656469746f722f762f756e737461626c65)](https://packagist.org/packages/jackiedo/dotenv-editor)[![License](https://camo.githubusercontent.com/9b443b26b04c27543b8bff45406c6f63081b187c95947fa631d041afdda0c244/68747470733a2f2f706f7365722e707567782e6f72672f6a61636b6965646f2f646f74656e762d656469746f722f6c6963656e7365)](https://packagist.org/packages/jackiedo/dotenv-editor)

Laravel Dotenv Editor is an the .env file editor (or files with same structure and syntax) for Laravel 5+. Now you can easily edit .env files with following features:

- Read raw content of file
- Read lines in file content
- Read setters (key-value-pair) in file content
- Determine one key name of setter if exists
- Append empty lines into file
- Append comment lines into file
- Append new or update exists setter lines into file
- Delete exists setter line in file
- Backup and restore file
- Manage backup files

Documentation
=============

[](#documentation)

Look at one of the following topics to learn more about Laravel Dotenv Editor

- [Versions and compatibility](#versions-and-compatibility)
- [Installation](#installation)
- [Configuration](#configuration)
    - [Auto backup mode](#auto-backup-mode)
    - [Backup location](#backup-location)
- [Usage](#usage)
    - [Working with facade](#working-with-facade)
    - [Using dependency injection](#using-dependency-injection)
    - [Loading file for working](#loading-file-for-working)
    - [Reading file content](#reading-file-content)
    - [Writing content into file](#writing-content-into-file)
    - [Backing up and restoring file](#backing-up-and-restoring-file)
    - [Method chaining](#method-chaining)
    - [Working with Artisan CLI](#working-with-artisan-cli)
    - [Exceptions](#exceptions)
- [License](#license)
- [Thanks from author](#thanks-for-use)

Versions and compatibility
--------------------------

[](#versions-and-compatibility)

Currently, Laravel Dotenv Editor only have version 1.x that is compatible with Laravel 5+ and later. This package is not support for Laravel 4.2 and earlier versions.

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

[](#installation)

You can install this package through [Composer](https://getcomposer.org).

- First, edit your project's `composer.json` file to require `jackiedo/dotenv-editor`:

```
...
"require": {
    ...
    "jackiedo/dotenv-editor": "1.*"
},
```

- Next, run the composer update command in your command line interface:

```
$ composer update
```

> **Note:** Instead of performing the above two steps, you can perform faster with the command line `$ composer require jackiedo/dotenv-editor:1.*`.

- Once update operation completes, the third step is add the service provider. Open `config/app.php`, and add a new item to the providers array:

```
...
'providers' => array(
    ...
    Jackiedo\DotenvEditor\DotenvEditorServiceProvider::class,
),
```

- The next step is add the follow line to the section `aliases` in file `config/app.php`:

```
'DotenvEditor' => Jackiedo\DotenvEditor\Facades\DotenvEditor::class,
```

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

[](#configuration)

To get started, you'll need to publish configuration file:

```
$ php artisan vendor:publish --provider="Jackiedo\DotenvEditor\DotenvEditorServiceProvider" --tag="config"
```

This will create a `config/dotenv-editor.php` file in your app that you can modify to set your configuration. Also, make sure you check for changes to the original config file in this package between releases.

#### Auto backup mode

[](#auto-backup-mode)

The option `autoBackup` is determine that your orignal file will be backed up before save or not.

#### Backup location

[](#backup-location)

The option `backupPath` is where that your file is backed up to. This value is the sub path (sub-folder) from root folder of project application.

Usage
-----

[](#usage)

#### Working with facade

[](#working-with-facade)

Laravel Dotenv Editor has a facade with name is `Jackiedo\DotenvEditor\Facades\DotenvEditor`. You can do any operation through this facade. For example:

```
