tomrf / dotenv
使用内置的parse_ini_file()函数的简单dotenv文件加载器
0.0.5
2023-08-02 13:13 UTC
Requires
- php: ^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.8
- phpmd/phpmd: ^2.12
- phpstan/phpstan: ^1.6
- phpunit/phpunit: ^9.5
- roave/security-advisories: dev-latest
- tomrf/readme-gen: ^0.0
README
使用PHP内置的parse_ini_file()函数和扫描模式INI_SCANNER_TYPED
(参见PHP手册)从dotenv文件中加载环境变量
这是一种简单、可靠且超级快速的方式来加载dotenv文件,无需任何花哨的功能。
📔 前往文档
安装
通过composer安装
composer require tomrf/dotenv
使用方法
$dotEnvLoader = new \Tomrf\DotEnv\DotEnvLoader(); // loadImmutable() will not overwrite existing environment variables $dotEnvLoader->loadImmutable(__DIR__ . '/.env'); // load() will overwrite existing environment variables $dotEnvLoader->load('/path/to/dotenv/file');
测试
composer test
许可证
本项目采用MIT许可证(MIT)发布。有关更多信息,请参阅LICENSE。
文档
📂 Tomrf\DotEnv\DotEnvLoader::class
使用parse_ini_file()的简单dotenv加载器。
load()
将dotenv文件加载到本地环境,覆盖任何已设置的环境变量。
public function load( string $filename ): void @throws \Tomrf\DotEnv\DotEnvLoaderException if parsing fails or if the file is not found
loadImmutable()
将dotenv文件加载到本地环境,同时保留任何现有环境变量。
public function loadImmutable( string $filename ): void @throws \Tomrf\DotEnv\DotEnvLoaderException if parsing fails or if the file is not found
使用📚tomrf/readme-gen于2023-04-21T13:16:14+00:00生成