railken / dotenv
v0.1.2
2018-12-27 17:20 UTC
Requires
- php: >=7.1
- vlucas/phpdotenv: ^2.5
Requires (Dev)
- phpunit/phpunit: ~7.0
This package is auto-updated.
Last update: 2024-11-28 07:28:17 UTC
README
This library is an extension of Dotenv that grants you the ability to update variables into the .env
file.
You can either update, append or remove a variable.
Requirements
PHP 7.1 and later.
Installation
You can install it via Composer by typing the following command:
composer require railken/dotenv
Usage
A simple usage looks like:
use Railken\Dotenv\Dotenv; // Location of the directory that contains the .env file $path = __DIR__; $dotenv = new Dotenv($path); $dotenv->load(); $dotenv->updateVariable("APP_KEY", "foo"); $dotenv->appendVariable("NEW_KEY", 2); $dotenv->removeVariable("NEW_KEY");
The class Railken\Dotenv\Dotenv
simply extends the class Dotenv\Dotenv
as you can see here
If you wish you can use directly the Railken\Dotenv\Storage
use Railken\Dotenv\Storage; // Location of the directory that contains the .env file $path = __DIR__; $storage = new Storage($path); $storage->update("APP_KEY", "foo"); $storage->append("NEW_KEY", 2); $storage->remove("NEW_KEY");