innoboxrr / laravel-env-editor
A laravel Package that supports .Env File, editing and backup
Requires
- php: ^8.3
- laravel/framework: ^13.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3
- innoboxrr/larapack-generator: ^7.0
- larastan/larastan: ^3.0
- orchestra/testbench: ^11.0
- phpunit/phpunit: ^11.5 || ^12.0
- rector/rector: ^2.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-14 04:20:28 UTC
README
Laravel .env Editor (plus GUI)
This Package allows to manage Laravel .env file values on the Fly (add, edit, delete keys), upload another .env or create backups
Management can be done through the user interface, or programmatically by using the EnvEditor Facade, without breaking the files structure.
The inspiration for this package was, Brotzka/laravel-dotenv-editor.
Installation:
-
Install package
composer require innoboxrr/laravel-env-editor
-
Publish assets
php artisan vendor:publish --provider=Innoboxrr\EnvEditor\ServiceProvider
This will publish all files:
- config -> env-editor.php
- views -> resources/views/vendor/env-editor/..
- lang -> resources/lang/vendor/env-editor.php
Or publish one tag (
config,translationsorviews). Always pass the provider: a bare--tag=configpublishes the config of every package that uses that tag.php artisan vendor:publish --provider=Innoboxrr\EnvEditor\ServiceProvider --tag=config php artisan vendor:publish --provider=Innoboxrr\EnvEditor\ServiceProvider --tag=translations php artisan vendor:publish --provider=Innoboxrr\EnvEditor\ServiceProvider --tag=views
Full documentation of the ecosystem, in Spanish and English: https://innoboxrr.github.io/docs/paquetes/laravel-env-editor.
Available Methods:
- getEnvFileContent
- keyExists
- getKey
- addKey
- editKey
- deleteKey
- getAllBackUps
- upload
- backUpCurrent
- getFilePath
- deleteBackup
- restoreBackUp
Example
EnvEditor::getEnvFileContent($fileName='') // Return The .env Data as Collection. // If FileName Is provided it searches inside backups Directory and returns these results EnvEditor::keyExists($key) // Search key existance in .env EnvEditor::getKey(string $key, $default = null) // Get key value from .env, EnvEditor::addKey($key, $value, array $options = []) // Adds new Key in .env file // As options can pass ['index'=>'someNumericIndex'] in order to place the new key after an other and not in the end, // or ['group'=>'MAIL/APP etc'] to place the new key oat the end of the group EnvEditor::editKey($key, $value) // Edits existing key value EnvEditor::deleteKey($key) EnvEditor::getAllBackUps() // Returns all Backup files as collection with some info like, created_date, content etc. EnvEditor::upload(UploadedFile $uploadedFile, $replaceCurrentEnv) // Gets an UploadedFile and stores it as backup or as current .env EnvEditor::backUpCurrent() // Backups current .env EnvEditor::getFilePath($fileName = '') // Returns the full path of a backup file. // If $fileName is empty returns the full path of the .env file EnvEditor::deleteBackup($fileName) EnvEditor::restoreBackUp()
User Interface
Note: user interface is disabled by default. You can enable it by changing the configuration option env-editor.route.enable
Securing the interface
Whoever reaches these routes can read the whole .env, including APP_KEY and every credential, and rewrite it. The route group uses ['web', 'auth'] by default, so guests are rejected, but any authenticated user still gets in. Restrict it to administrators before enabling it, in config/env-editor.php:
'route' => [ 'enable' => true, // your own admin middleware... 'middleware' => ['web', 'auth', 'admin'], // ...and/or a Gate ability checked on every action 'gate' => 'manage-env', ],
// App\Providers\AppServiceProvider::boot() Gate::define('manage-env', fn (User $user): bool => $user->is_admin);
With gate set, a guest gets 401 (or the redirect to your login page) and an authenticated user without the ability gets 403. Laravel redirects guests to the route named login; if your app has none, a browser request from a guest fails with "Route [login] not defined" instead of redirecting, while JSON requests still get 401.
Saving the .env schedules php artisan optimize a minute later only when the configuration is cached. Without a config cache the new values are read on the next request.
User Interface Contains three Tabs






