Skip to content

Yet another .env parser/loader improved for performance

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

rfussien/dotenv

Repository files navigation

dotenv

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Requirements

PHP >= 5.6 | >= 7.0 | >= 7.1
⚠️ HHVM not supported so far ⚠️

Install

Via Composer

$ composer require rfussien/dotenv

Usage

$dotenv = new Rfussien\Dotenv\Loader(__DIR__);
$dotenv->load();

// optionally you can set a different filename (by defaul .env)
$dotenv = new Rfussien\Dotenv\Loader(__DIR__, '.my.env');
$dotenv->load();

Why should I use this dotenv loader instead of another ?

This package is meant to be faster than the other dotenv loaders.
But please, don't believe me, check my small benchmark out, and try it by yourself.

It has less features, but come on, it's about a config file and a minimum computing should be done...

IMHO:

  • A real boolean MUST NOT be between quotes
  • A string SHOULD be between quotes or double quotes
  • An empty value is not null, but an empty string
  • Computing nested values every single time my app runs is a waste of time

Results

In the .env type value
K01=true bool true
K02=tRuE bool true
K03="true" string(4) "true"
K04=on bool true
K05=On bool true
K06="on" string(2) "on"
K07=yes bool true
K08=Yes bool true
K09="yes" string(3) "yes"
K10=false bool false
K11=fAlSe bool false
K12="false" string(5) "false"
K13=off bool false
K14=Off bool false
K15="off" string(3) "off"
K16=no bool false
K17=No bool false
K18="no" string(2) "no"
K19=1 int 1
K20=1.1 double 1.1
K21=value string(5) "value"
K22="value" string(5) "value"
K23="VaLuE" string(5) "VaLuE"
K24=VaLuE string(5) "VaLuE"
K25="value " value" string(13) "value " value"
K26="value "value" value" string(19) "value "value" value"
K27="value 'value' value" string(19) "value 'value' value"
K28="" string(0) ""
K29= value string(5) "value"
K30='value' string(5) "value"
K31='' string(0) ""
K32= string(0) ""
K33=null NULL NULL

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email remi.fussien@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

Yet another .env parser/loader improved for performance

Topics

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Packages

No packages published