PHP code example of enjoys / dotenv-writer
1. Go to this page and download the library: Download enjoys/dotenv-writer 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/ */
enjoys / dotenv-writer example snippets
$envPath = __DIR__.'/.env';
$dotenvWriter = new \Enjoys\DotenvWriter\DotenvWriter($envPath);
$dotenvWriter->addLine(
new \Enjoys\Dotenv\Parser\Lines\CommentLine('sdfghj')
);
$dotenvWriter->addLine(
new \Enjoys\Dotenv\Parser\Lines\EmptyLine()
);
$dotenvWriter->addLine(
new \Enjoys\Dotenv\Parser\Lines\EnvLine(
new \Enjoys\Dotenv\Parser\Env\Key('VAR'),
new \Enjoys\Dotenv\Parser\Env\Value('value'),
new \Enjoys\Dotenv\Parser\Env\Comment('comment')
)
);
$dotenvWriter->addLines([
//...
]);
$dotenvWriter->setEnv('KEY', 'Value', 'Comment')
$dotenvWriter->setEnvIf('KEY', 'newValue', 'conditionValue')
$dotenvWriter->addEnvIfNotExist()