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

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

encodia/laravel-dotenv-editor
=============================

The .env file editor tool for Laravel 5.8+

3.0.0(2y ago)090MITPHP

Since Jan 18Pushed 2y agoCompare

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

READMEChangelogDependencies (4)Versions (5)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 the .env file editor (or files with same structure and syntax) for Laravel 5.8+. Now you can easily edit .env files with the following features:

- Read raw content of file.
- Read entries of file content.
- Read setters (key-value-pair) in file content.
- Check for existence of setter.
- Append empty lines to file content.
- Append comment lines to file content.
- Append new or update an existing setter entry.
- Update comment of an existing setter entry.
- Update export status of an existing setter entry.
- Delete existing setter entry in file content.
- Backup and restore file content.
- Manage backuped files.

Versions and compatibility
==========================

[](#versions-and-compatibility)

Laravel Dotenv Editor is compatible with Laravel 5.8 and later.

Important note for the version `2.x`
====================================

[](#important-note-for-the-version-2x)

After the release of `1.2.1`, version 1.x will be discontinued in favor of a new version (version `2.x`) with some changes to be compatible with the parsing method of `vlucas/phpdotenv` package. Version `2.x` has changed quite a lot compared to the previous version. If you have used earlier versions of this package, please re-read the instructions carefully.

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

[](#documentation)

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

- [Installation](#installation)
- [Configuration](#configuration)
    - [Auto backup mode](#auto-backup-mode)
    - [Backup location](#backup-location)
    - [Always create backup folder](#always-create-backup-folder)
- [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)
    - [Edit file content](#edit-file-content)
    - [Backing up and restoring file](#backing-up-and-restoring-file)
    - [Method chaining](#method-chaining)
    - [Working with Artisan CLI](#working-with-artisan-cli)
    - [Exceptions](#exceptions)

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

[](#installation)

You can install this package through [Composer](https://getcomposer.org). At the root of your application directory, run the following command (in any terminal client):

```
$ composer require jackiedo/dotenv-editor
```

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

[](#configuration)

To start using the package, you should publish the configuration file so that you can configure the package as needed. To do that, run the following command (in any terminal client) at the root of your application:

```
$ 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. Currently there are the following settings:

#### Auto backup mode

[](#auto-backup-mode)

The `autoBackup` setting allows your original file to be backed up automatically before saving. Set it to `true` to agree.

#### Backup location

[](#backup-location)

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

#### Always create backup folder

[](#always-create-backup-folder)

The `alwaysCreateBackupFolder` setting is used to request that the backup folder always be created, whether or not the backup is performed.

Usage
-----

[](#usage)

### Working with facade

[](#working-with-facade)

Laravel Dotenv Editor has a facade with the name `Jackiedo\DotenvEditor\Facades\DotenvEditor`. You can perform all operations through this facade.

**Example:**

```
