PHP code example of psecio / secure_dotenv

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

    

psecio / secure_dotenv example snippets



file = __DIR__.'/keyfile';
$envFile = __DIR__.'/.env';

$d = new \Psecio\SecureDotenv\Parser($keyfile, $envFile);

// The contents here is the set of all decrypted values fron the .env
print_r($d->getContent());


 = $_ENV['ENCRYPTION_KEY'];
$envFile = __DIR__.'/.env';

$d = new \Psecio\SecureDotenv\Parser($key, $envFile);



file = __DIR__.'/keyfile';
$envFile = __DIR__.'/.env';

$d = new \Psecio\SecureDotenv\Parser($keyfile, $envFile);

$keyName = 'test1';
$keyValue = 'foobarbaz';

if ($d->save($keyName, $keyValue)) {
    echo 'Save successful';
} else {
    echo 'There was an error while saving the value.';
}

php vendor/bin/generate-defuse-key