enjoys/dotenv-writer

0.1.4 2023-01-22 17:30 UTC

This package is auto-updated.

Last update: 2024-11-05 02:18:09 UTC


README

$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()