PHP code example of izica / laravel-env-secure

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

    

izica / laravel-env-secure example snippets


php artisan env:secure {env key} {--cli} {--decrypt}

php artisan env:secure DB_PASSWORD

//config/database.php

use \Izica\EnvSecure\EnvSecure;

[
    //...
    'connections' => [
         //...
        'mysql' => [
            //...
            'password' => EnvSecure::env('DB_PASSWORD', ''),
        ]
    ]
]

//config env-secure.php
return [
    "prefix"    => env('ENV_SECURE_PREFIX', 'scr::'),
    "algorithm" => env('ENV_SECURE_ALGORITHM', 'AES-128-CTR'),  // https://www.php.net/manual/en/function.openssl-get-cipher-methods.php
    "iv"        => env('ENV_SECURE_IV', 1234567891011121),
    "key"       => env('ENV_SECURE_KEY', null), //APP_KEY by default. If you change the key after the values have been secured, you will not be able to decrypt the values in the future.
];

//config env-secure.php
return [
   //...
    "key" => "kovdj43ksadjl32jlk"
];
bash
php artisan vendor:publish --provider="Izica\\EnvSecure\\EnvSecureServiceProvider"