Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/railken/dotenv
This library is an extension of vlucas/phpdotenv that grants you the ability to update variables into the `.env` file. You can either update, append or remove a variable.
https://github.com/railken/dotenv
dotenv env environment file persist put set setter store update
Last synced: 3 days ago
JSON representation
This library is an extension of vlucas/phpdotenv that grants you the ability to update variables into the `.env` file. You can either update, append or remove a variable.
- Host: GitHub
- URL: https://github.com/railken/dotenv
- Owner: railken
- License: mit
- Created: 2018-12-26T15:01:10.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-12-27T17:36:22.000Z (about 6 years ago)
- Last Synced: 2024-11-24T05:17:47.285Z (2 months ago)
- Topics: dotenv, env, environment, file, persist, put, set, setter, store, update
- Language: PHP
- Homepage:
- Size: 38.1 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dotenv
[![Build Status](https://travis-ci.org/railken/dotenv.svg?branch=master)](https://travis-ci.org/railken/dotenv)
This library is an extension of [Dotenv](https://github.com/vlucas/phpdotenv) 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](https://getcomposer.org/) by typing the following command:
```bash
composer require railken/dotenv
```## Usage
A simple usage looks like:
```php
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](https://github.com/railken/dotenv/blob/master/src/Dotenv.php#L7)
If you wish you can use directly the `Railken\Dotenv\Storage`
```php
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");
```