All Projects → devcoder-xyz → php-dotenv

devcoder-xyz / php-dotenv

Licence: MIT License
Parses .env files

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to php-dotenv

ini
📝 Go INI config management. support multi file load, data override merge. parse ENV variable, parse variable reference. Dotenv file parse and loader. INI配置读取管理,支持多文件加载,数据覆盖合并, 解析ENV变量, 解析变量引用。DotEnv 解析加载
Stars: ✭ 72 (+50%)
Mutual labels:  dotenv, dotenv-loader
php-env
A small and fast .env loader for PHP
Stars: ✭ 19 (-60.42%)
Mutual labels:  dotenv, dotenv-parser
angular-cli-envvars
Example project for my article "Angular CLI and OS Environment Variables"
Stars: ✭ 56 (+16.67%)
Mutual labels:  dotenv
node
💪 Simple & Secure Config Management for Node.js 💪
Stars: ✭ 32 (-33.33%)
Mutual labels:  dotenv
dotenv-vault
[deprecated] simple dotenv encrypt & decrypt tool inspired by yaml_vault
Stars: ✭ 27 (-43.75%)
Mutual labels:  dotenv
express-ts-api-boilerplate
Express TypeScript API Boilerplate
Stars: ✭ 15 (-68.75%)
Mutual labels:  dotenv
express-mongoose-es8-rest-api
A Boilerplate for developing Rest api's in Node.js using express with support for ES6,ES7,ES8 ,Mongoose,JWT for authentication,Standardjs for linting
Stars: ✭ 20 (-58.33%)
Mutual labels:  dotenv
exenv
Exenv makes loading environment variables from external sources easy.
Stars: ✭ 35 (-27.08%)
Mutual labels:  dotenv
envfile
Parse and write environment files with Node.js
Stars: ✭ 42 (-12.5%)
Mutual labels:  dotenv
dotenv
Loads environment variables from `.env`.
Stars: ✭ 88 (+83.33%)
Mutual labels:  dotenv
php-traits
A collection of (more or less) useful traits for PHP7.2+
Stars: ✭ 17 (-64.58%)
Mutual labels:  dotenv
dump-env
A utility tool to create .env files
Stars: ✭ 81 (+68.75%)
Mutual labels:  dotenv
ts-dotenv
Strongly-typed environment variables for Node.js
Stars: ✭ 18 (-62.5%)
Mutual labels:  dotenv
dotenv validator
This gem check if required env variables are present and its format using the .env and .env.sample files from Dotenv.
Stars: ✭ 33 (-31.25%)
Mutual labels:  dotenv
twitch-chat-visualizer
A Node.js Project. Would you like to see your chat stream with a custom design? This is for you!
Stars: ✭ 14 (-70.83%)
Mutual labels:  dotenv
dotenv
Load .env files in crystal
Stars: ✭ 16 (-66.67%)
Mutual labels:  dotenv
ngx-env
Easily inject environment variables into your Angular applications
Stars: ✭ 73 (+52.08%)
Mutual labels:  dotenv
cypress-dotenv
Cypress plugin that enables compatability with dotenv
Stars: ✭ 47 (-2.08%)
Mutual labels:  dotenv
nest-typed-config
Intuitive, type-safe configuration module for Nest framework ✨
Stars: ✭ 47 (-2.08%)
Mutual labels:  dotenv
dotenv.net
A library to read .env files in a .NET Core environment
Stars: ✭ 126 (+162.5%)
Mutual labels:  dotenv

php-dotenv

Loads environment variables from .env file to getenv(), $_ENV and $_SERVER.

Latest Stable Version Total Downloads Latest Unstable Version License

APP_ENV=dev
DATABASE_DNS=mysql:host=localhost;dbname=test;
DATABASE_USER="root"
DATABASE_PASSWORD=root
MODULE_ENABLED=true

Load the variables

<?php
use DevCoder\DotEnv;

$absolutePathToEnvFile = __DIR__ . '/.env';

(new DotEnv($absolutePathToEnvFile))->load();

Use them!

/**
 * string(33) "mysql:host=localhost;dbname=test;" 
 */
var_dump(getenv('DATABASE_DNS'));

/**
 * Removes double and single quotes from the variable:
 * 
 * string(4) "root" 
 */
var_dump(getenv('DATABASE_USER'));

/**
 * Processes booleans as such:
 * 
 * bool(true) 
 */
var_dump(getenv('MODULE_ENABLED'));

Ideal for small project

Simple and easy!

Processors

Also the variables are parsed according to the configuration passed as parameter to the constructor. The available processors are:

BooleanProcessor

VARIABLE=false will be processed to bool(false)

NOTE: VARIABLE="true" will be processed to string(4) "true"

QuotedProcessor

VARIABLE="anything" will be processed to string(8) "anything"

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].