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

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

quhang/dotenv-editor
====================

The .env file editor tool for Laravel 5+

1.0.10(8y ago)127MITPHPPHP &gt;=5.4.0

Since May 15Pushed 8y ago1 watchersCompare

[ Source](https://github.com/zm-john/Laravel-Dotenv-Editor)[ Packagist](https://packagist.org/packages/quhang/dotenv-editor)[ RSS](/packages/quhang-dotenv-editor/feed)WikiDiscussions master Synced 2w ago

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

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

[](#laravel-dotenv-editor)

\[fork from [JackieDo/Laravel-Dotenv-Editor](https://github.com/JackieDo/Laravel-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 `quhang/dotenv-editor`:

```
...
"require": {
    ...
    "quhang/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 quhang/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:

```
