Laravel .env File Moderator
Next, run the Composer command to install the latest stable version:
composer require munna/dot-env-editor
##After installing, you should follow these two step:
Add this provider link at your config/app.php file into the providers array.
Munna\DotEnvEditor\DotEnvEditorServiceProvider::class,
And
Add this facades link at your config/app.php file into the aliases array.
'DotEnvEditor' => Munna\DotEnvEditor\Facades\DotEnvEditor::class,
to create a class instance
use Munna\DotEnvEditor\DotEnvEditor;
$env = new DotEnvEditor();
$env->env_array();
// Use this class as your demand.
When you are already set the facade class into your aliases array at the config/app.php file.
use DotEnvEditor;
$env_array = DotEnvEditor::env_array();
// Example
use DotEnvEditor;
$env_array = DotEnvEditor::env_array();
use DotEnvEditor;
$key = "APP_NAME";
$key_val = DotEnvEditor::env_key($key);
use DotEnvEditor;
$key = "APP_NAME";
$key_check = DotEnvEditor::env_key_check($key);
use DotEnvEditor;
$key = "NEW_KEY";
$value = "NEW_VALUE"; // or 1254 or https://www.domain.com
$add_key = DotEnvEditor::add_key($key, $value);
use DotEnvEditor;
$key = "NEW_KEY";
$value = "NEW_VALUE";
$existing_key = "EXISTING_KEY";
$add_key_after = DotEnvEditor::add_key_after($key, $value, $existing_key);
use DotEnvEditor;
$key = "NEW_KEY";
$value = "NEW_VALUE";
$existing_key = "EXISTING_KEY";
$add_key_before = DotEnvEditor::add_key_before($key, $value, $existing_key);
use DotEnvEditor;
$key = "EXISTING_KEY";
$value = "NEW_VALUE";
$update_key = DotEnvEditor::update_key($key, $value);
$array = [
"APP_NAME" => "TEST_LARAVEL_APP",
"MAIL_USERNAME" => "TEST_MAIL_USERNAME",
"MAIL_PASSWORD" => "TEST_MAIL_PASSWORD",
];
$env = DotEnvEditor::update_multiple_key($array);
return $env;
use DotEnvEditor;
$key = "EXISTING_KEY";
$remove_key = DotEnvEditor::remove_key($key);
use DotEnvEditor;
$env_array = DotEnvEditor::env_file();
use DotEnvEditor;
$env_row_file = DotEnvEditor::env_row_file();
This package is open-sources and licensed under the MIT license.
Thank you very much. Please give a star.