climbx/dotenv
Composer 安装命令:
composer require climbx/dotenv
包简介
.env files manager
README 文档
README
Dotenv component parses .env files and add them to both $_ENV and
$_SERVER.
Install
$ composer require climbx/dotenv
Usage
# .env foo=bar bar=baz
// PHP use Climbx\Dotenv\Dotenv; $dotenv = new Dotenv(); $envPath = __DIR__ . '/.env'; /* * Loads env vars into $_ENV and $_SERVER * without overwriting existing variables */ $dotenv->load($envPath); /* * Loads env vars into $_ENV and $_SERVER * if a variable already exists, it is overridden. */ $dotenv->overload($envPath);
Env files syntax
# Comment line foo=bar # End line comment bar='this is a single quotted value' # allows whitespaces baz="this is a double quotted value" num=1234
Variables references
Simple var reference:
foo=bar baz=$foo # outputs ['baz' => 'bar']
Multiple var references:
foo=1 bar=2 spaced="$foo and $bar" # outputs ['spaced' => '1 and 2'] collapsed=$one$two # outputs ['collapsed' => '12']
Partial var references:
foo="one" bar="two" baz=${foo}/${bar}/three # outputs ['baz' => 'one/two/three']
Escaped var declaration char
foo=bar echaped1=\$foo # outputs ['echaped1' => '$foo'] echaped2=\${foo} # outputs ['echaped2' => '${foo}']
Missing var reference.
Missing references don't throw an exception. If a reference is not found,
the value is set to an empty string.
missing1=$foo # outputs ['missing1' => ''] missing2=${foo} # outputs ['missing2' => '']
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-06-10