PHP code example of balint-horvath / dotenv-php

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

    

balint-horvath / dotenv-php example snippets


new \BalintHorvath\DotEnv\DotEnv($path)


define('APP_DIR', dirname(__FILE__) . '/');

PP_DIR);


    $dotenv->{variable}
    $dotenv->{section}->{variable}

    $dotenv->API->apiUser

    API User: <?=$dotenv->API->apiUser

    $_ENV['{variable}']
    $_ENV['{section}']['{variable}']

    $_ENV['API_apiUser']

    API User: <?=$_ENV['API_apiUser']

    getenv('variable')
    getenv('section_variable')

    getenv('API_apiUser')

    API User: <?=getenv('API_apiUser')

    $dotenv[{variable}]
    $dotenv[{section}][{variable}]

    $dotenv['API']['apiUser']

    API User: <?=$dotenv['API']['apiUser']
bash
curl -sS https://getcomposer.org/installer | php
bash
composer 
bash
php composer.phar