Git Product home page Git Product logo

dotenv's Introduction

DotEnv

Build Status

Read '.env' file to a static array.

Installation

composer require zablose/dotenv

Usage

Read '.env' file(s)

Probably in your index.php after auto loader.

use Zablose\DotEnv\Env;

// Auto loader

(new Env())->setArrays(['PROTECTED'])
    ->read(__DIR__.'/../.env')
    ->read(__DIR__.'/../.env-extra');

Get ENV

use Zablose\DotEnv\Env;

$db_name = Env::string('DB_NAME', 'dotenv');
$db_password = Env::string('DB_PASSWORD');
$db_port = Env::int('DB_PORT');

Or

Works, if helper function is in use - added to the project's composer autoload -> files section.

$db_name = env_string('DB_NAME', 'dotenv');
$db_password = env_string('DB_PASSWORD');
$db_port = env_int('DB_PORT');

What is supported?

Look at ENVs testing examples for more info.

Variables

USER=username
EMAIL=${USER}@domain.com

Arrays

PROTECTED_0=_token
PROTECTED_1=password

Value Types

Type Example
Boolean DEBUG_ON=true
Float PI=3.14
Integer RAM=128
String GREETING=Welcome back!

Development

Check submodule's readme for more details about development environment used.

Hosts

Append to /etc/hosts.

127.0.0.1       dotenv.zdev
127.0.0.1       www.dotenv.zdev

Quick Start

$ git clone -b 'dev' --single-branch --depth 1 https://github.com/zablose/dotenv.git dotenv
$ cd dotenv
$ git submodule update --init

# Copy env file, then ammend it to your needs.
$ cp .env.example .env

$ docker-compose -p zdev up -d

# To see post-script logs, while container is starting.
$ tail -f docker-damp/logs/all.log

# To enter container, using Bash shell.
$ docker exec -it dotenv-damp bash

(dotenv-damp)$ phpunit

License

This package is free software distributed under the terms of the MIT license.

dotenv's People

Contributors

zablose avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.