PHP code example of tal7aouy / dotenv

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

    

tal7aouy / dotenv example snippets

 php
$dotenv = new Dotenv();

$dotenv->load(base_path('.env'));
$dotenv->heading('DB_CONNECTION');
$dotenv->set('DB_CONNECTION', 'mysql');
$dotenv->set('DB_HOST', '127.0.0.1');
$dotenv->set('DB_PORT', '3306');
$dotenv->set('DB_DATABASE', 'demo');
$dotenv->set('DB_USERNAME', 'root');
$dotenv->set('DB_PASSWORD', '');
$dotenv->getEnv('DB_DATABASE'); // demo
$dotenv->save();