pyncer/dotenv

A Dotenv WriterInterface implementation to write .env values to constants.

v1.2.1 2024-02-25 14:58 UTC

This package is auto-updated.

Last update: 2024-04-25 15:20:46 UTC


README

A phpdotenv implementation to read and write .env values from and to constants.

Installation

Install via Composer:

$ composer require pyncer/dotenv

Example

use Dotenv\Dotenv;
use Dotenv\Repository\RepositoryBuilder;
use Pyncer\Dotenv\ConstAdapter;

// ...

$repository = RepositoryBuilder::createWithNoAdapters()
    ->addAdapter(new ConstAdapter('Vendor\\Namespace'))
    ->immutable()
    ->make();

$dotenv = Dotenv::create($repository, getcwd());
$dotenv->load();

// ...

echo \Vendor\Namespace\MY_ENV_VARIABLE;