Giter Club home page Giter Club logo

perl-dotenv's Introduction

Perl Simple DotEnv

load enviroment vaiabled with Perl from a file in .env (dotenv) format.

Server Install

Install the module you Perl module path.

  1. load module and call sub source_dotenv();
use DotenvSimple;
DotenvSimple::source_dotenv('/tmp/.env');
  1. Here's a sample /tmp/.env, can follow any of the below formats
# <--- hashes or comments are ignored
# we also ignore export, white spaces and semicolons
export  DD_DATABASE_NAME = issm_lists_stage;
# single and double quotes for values are allowed
DD_DATABASE_USER=dev
DD_DATABASE_PASSWD=dev
DD_DATABASE_HOST='192.168.33.1'
DD_DATABASE_PORT='3306';
DD_DATABASE_Type = "mysql";

Refferancing key a key to get teh value from the above .env files:

print $ENV{DD_DATABASE_HOST}; output > 192.168.33.1

Options

Loading dotenv in this order. Once found it will stop searching for dotenv.

  1. You pass the path of you dotenv file as a parameter DotenvSimple::source_dotenv('/tmp/.env');
  2. If you set a Perl accessable enviroment parameter $ENV{DOTENV_FILE} the subroutine will use the value of this vaiable. Use case would be to define this in apache vhost configs like so
<VirtualHost hostname:80>
   ...
   SetEnv DOTENV_FILE /tmp/.env
   ...
</VirtualHost>
  1. Generally when using Apache, the document root variable $ENV{DOCUMENT_ROOT}, is loaded into perl. if using HTTPD it will also search for .env in your document root.

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.