zenlix/zenenv

A package for editing the .env file

1.4 2016-07-25 11:45 UTC

This package is not auto-updated.

Last update: 2024-12-19 02:07:30 UTC


README

License Total Downloads

ZenEnv

PHP class that helps work with .env

Install

composer require zenlix/zenenv

Use

use ZenEnv\ZenEnv;

Initializing ZenEnv

$env = new ZenEnv('/home/rustem/web/public_html/.env');

Get array of key/values

$env->get();

Result:

print_r($env-get());
['PARAM1'=>'VALUE1','PARAM2'=>'VALUE2']

Delete by keys

$env->delete(['KEY1', 'KEY2']);

Before:

PARAM1=VALUE1
PARAM2=VALUE2
PARAM3=VALUE3

After:

PARAM3=VALUE3

Add key/value

$env->add([
'KEY'=>'VAL',
'KEY2'=>'VAL2'
]);

Before:

PARAM1=VALUE1
PARAM2=VALUE2
PARAM3=VALUE3

After:

PARAM1=VALUE1
PARAM2=VALUE2
PARAM3=VALUE3
KEY=VAL
KEY2=VAL2

Change key/value

$env->set([
'PARAM1'=>'VALUE',
'PARAM2'=>'VALUE'
]);

Before:

PARAM1=VALUE1
PARAM2=VALUE2
PARAM3=VALUE3

After:

PARAM1=VALUE
PARAM2=VALUE
PARAM3=VALUE3