PHP code example of munna / dot-env-editor

1. Go to this page and download the library: Download munna/dot-env-editor library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

munna / dot-env-editor example snippets


Munna\DotEnvEditor\DotEnvEditorServiceProvider::class,

'DotEnvEditor' => Munna\DotEnvEditor\Facades\DotEnvEditor::class,

use Munna\DotEnvEditor\DotEnvEditor;
$env = new DotEnvEditor();
$env->env_array();
// Use this class as your demand.

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();