PHP code example of railken / dotenv

1. Go to this page and download the library: Download railken/dotenv 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/ */

    

railken / dotenv example snippets


use Railken\Dotenv\Dotenv;

// Location of the directory that contains the .env file
$path = __DIR__; 

$dotenv = new Dotenv($path);
$dotenv->load();

$dotenv->updateVariable("APP_KEY", "foo");
$dotenv->appendVariable("NEW_KEY", 2);
$dotenv->removeVariable("NEW_KEY");

use Railken\Dotenv\Storage;

// Location of the directory that contains the .env file
$path = __DIR__; 

$storage = new Storage($path);
$storage->update("APP_KEY", "foo");
$storage->append("NEW_KEY", 2);
$storage->remove("NEW_KEY");