1. Go to this page and download the library: Download vilnisgr/env-editor 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/ */
vilnisgr / env-editor example snippets
use VilnisGr\EnvEditor\Writer\DotenvWriter;
$writer = new DotenvWriter();
$writer->load('.env');
$writer->set('APP_ENV', 'production');
$writer->save();
$writer = new DotenvWriter();
$writer->load('.env');
$schema->group('DB_', function (EnvSchema $db) {
$db->
$factory = new EnvConfigFactory($schema, $writer);
$config = $factory->make(AppConfig::class);
final class AppConfig
{
public function __construct(
public string $appName,
public int $dbPort,
public bool $debug
) {}
}
final class AppConfig
{
public function __construct(
public string $appName, // maps to APP_NAME
public int $dbPort, // maps to DB_PORT
public bool $debug // maps to DEBUG
) {}
}
use VilnisGr\EnvEditor\Writer\DotenvWriter;
use VilnisGr\EnvEditor\Schema\EnvSchema;
use VilnisGr\EnvEditor\Schema\EnvConfigFactory;
$writer = new DotenvWriter();
$writer->load('.env');
$schema = EnvSchema::make()
->