This package is abandoned and no longer maintained. No replacement package was suggested.

Configuration loader from .env files

v2.1.2 2017-11-24 05:38 UTC

This package is not auto-updated.

Last update: 2021-10-04 19:29:11 UTC


README

Build Status Scrutinizer Code Quality Packagist version Code Coverage

Settings loading module for the Daedalus web application framework.

Installation

This module is typically used as part of a Daedalus web application. If you'd like to use it on your own non-Daedalus project, you can add the following to your composer.json file:

{
  "require": {
    "daedalus-web/dotenv": "^2.0"
  }
}

Usage

This module automatically reads settings from .env named files, and from environment variables passed into your instance by a cloud service provider.

// Setting your file up to use Dotenv
use Daedalus\Dotenv\Dotenv as Dotenv;

// Getting a setting
Dotenv::get('DATABASE_PASSWORD');
Dotenv::get('PROJECT_ROOT');

Env File Locations

Dotenv can read a number of different file types, from a number of different locations. Your file must be named .env for the parser to detect it.

We currently support these locations:

  • In your project root, next to your composer.json file
  • A config directory one level deeper inside your project root, at /project_root/config/.env

We currently support the following file syntax type:

  • A traditional Key=Value syntax, eg DATABASE_PASSWORD=pocahontas. One value per line.

Order of Precedence

Your .env file settings will always take precedence over your system environment settings.

For .env file locations, the order of precedence is:

  • /.env
  • /config/.env
  • /storage/config/.env

About

Requirements

Daedalus Dotenv is fully tested to work with:

  • PHP 7.0
  • PHP 7.1

Strictly speaking, this module can be modified to support PHP 5.5+, however we use strict variable typing that is not available in PHP versions before 7.0. Because PHP 5.6 is no longer receiving active support (and will only be receiving security updates for another year), we strongly recommend starting any new project with PHP 7 or later.

Submitting bugs and feature requests

Bugs and feature request are tracked on GitHub

Author

Josh Grancell - josh@joshgrancell.com - https://github.com/jgrancell

License

Daedalus Dotenv is licensed under the MIT License - see the LICENSE file for details