PHP code example of tofuma / env-exporter
1. Go to this page and download the library: Download tofuma/env-exporter 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/ */
tofuma / env-exporter example snippets
use Tofuma\EnvExporter\EnvExporter;
// Generate .env file from .env.example
EnvExporter::generate('.env.example', '.env');
// Or get the key-value pairs as an array (without writing to file)
$pairs = EnvExporter::generate('.env.example', '.env', true);
print_r($pairs);
// Output: ['APP_NAME' => 'MyApp', 'DB_HOST' => 'localhost', ...]
// Generate file and get the count of exported variables
$count = EnvExporter::generateAndReport('.env.example', '.env');
echo "Exported {$count} variables";