linna/dotenv

Linna .env tool

v1.1.1 2022-02-19 17:00 UTC

This package is auto-updated.

Last update: 2024-11-21 01:20:04 UTC


README

Linna Logo
Linna dotenv Logo

Tests Scrutinizer Code Quality Code Coverage StyleCI PDS Skeleton PHP 7.2

About

This package provide a way to load .env files values as environement variable, it was insiperd by nodejs counterpart.

Requirements

This package require php 7.2

Installation

With composer:

composer require linna/dotenv

Usage

.env.test file as example

APP=linna
APP_ENV=production
USER=user.name@linna.tools
FOO=foo
BAR=bar
BAZ=baz

php code for get above values

$env = new Linna\DotEnv\DotEnv();
$env->load('.env.test');

$app = $env->get('APP');
$app_env = $env->get('APP_ENV');

//string 'linna' (length=5)
var_dump($app);

//string 'production' (length=10)
var_dump($app_env);

environment information in phpinfo()

phpinfo(INFO_ENVIRONMENT);

phpinfo(INFO_ENVIRONMENT)

Notes

DotEnv class use php function getenv and putenv then key and values will not be loaded in $_ENV superglobal.