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

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

mifesta/dotenv-editor
=====================

The .env file editor tool for Laravel 5+

1.0.2(6y ago)086MITPHPPHP &gt;=5.4.0

Since Aug 28Pushed 6y ago1 watchersCompare

[ Source](https://github.com/Mifesta/laravel-dotenv-editor)[ Packagist](https://packagist.org/packages/mifesta/dotenv-editor)[ RSS](/packages/mifesta-dotenv-editor/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (3)Dependencies (3)Versions (4)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/fc88a5697176cc2e6b6c92945e5e74d4f243bdacb7a375a6484829ef8f5f943f/68747470733a2f2f706f7365722e707567782e6f72672f6d6966657374612f646f74656e762d656469746f722f762f737461626c65)](https://packagist.org/packages/mifesta/dotenv-editor)[![Total Downloads](https://camo.githubusercontent.com/2f5b2a79e71606f37a09427c4165f189f5842d960ed8d3d530e9a3f56a4c95be/68747470733a2f2f706f7365722e707567782e6f72672f6d6966657374612f646f74656e762d656469746f722f646f776e6c6f616473)](https://packagist.org/packages/mifesta/dotenv-editor)[![Latest Unstable Version](https://camo.githubusercontent.com/62560922ec443c910baf2d0d2564bfc8302454f3226c9bbb740732899a2888b4/68747470733a2f2f706f7365722e707567782e6f72672f6d6966657374612f646f74656e762d656469746f722f762f756e737461626c65)](https://packagist.org/packages/mifesta/dotenv-editor)[![License](https://camo.githubusercontent.com/7c9b2d2c7fcb2def9db03153da29dd3d66c4df0d7b9dc252cdc8f549ddb8a456/68747470733a2f2f706f7365722e707567782e6f72672f6d6966657374612f646f74656e762d656469746f722f6c6963656e7365)](https://packagist.org/packages/mifesta/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)
        - [Reading raw content](#reading-raw-content)
        - [Reading content by lines](#reading-content-by-lines)
        - [Reading content by keys](#reading-content-by-keys)
        - [Determine if key is exists](#determine-if-key-is-exists)
        - [Get value of a key](#get-value-of-a-key)
    - [Writing content into file](#writing-content-into-file)
        - [Add an empty line into buffer](#add-an-empty-line-into-buffer)
        - [Add a comment line into buffer](#add-a-comment-line-into-buffer)
        - [Add or update a setter into buffer](#add-or-update-a-setter-into-buffer)
        - [Add or update multi setter into buffer](#add-or-update-multi-setter-into-buffer)
        - [Delete a setter line in buffer](#delete-a-setter-line-in-buffer)
        - [Delete multi setter lines in buffer](#delete-multi-setter-lines-in-buffer)
        - [Save buffer into file](#save-buffer-into-file)
    - [Backing up and restoring file](#backing-up-and-restoring-file)
        - [Backup your file](#backup-your-file)
        - [Get all backup versions](#get-all-backup-versions)
        - [Get latest backup version](#get-latest-backup-version)
        - [Restore your file from latest backup or other file](#restore-your-file-from-latest-backup-or-other-file)
        - [Delete one backup file](#delete-one-backup-file)
        - [Delete multi backup files](#delete-multi-backup-files)
        - [Change auto backup mode](#change-auto-backup-mode)
    - [Method chaining](#method-chaining)
    - [Working with Artisan CLI](#working-with-artisan-cli)
- [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 `mifesta/dotenv-editor`:

```
"require": {
    // other reqire packages
    "mifesta/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 mifesta/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(
    // other providers
    Mifesta\DotenvEditor\DotenvEditorServiceProvider::class,
),
```

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

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

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

[](#configuration)

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

```
$ php artisan vendor:publish --provider="Mifesta\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 `Mifesta\DotenvEditor\Facades\DotenvEditor`. You can do any operation through this facade. For example:

```
