remotelyliving/php-env
Composer 安装命令:
composer require remotelyliving/php-env
包简介
A library to marshall environment variables from environments
README 文档
README
php-env
🌎 An Environment Abstraction for PHP 🌎
Use Cases
If you want a boundary between you and your runtime environment, this library can help. If you like to use .env files this library can help.
Installation
composer require remotelyliving/php-env
Usage
Create The Application Environment
<?php // needs to be set before hand through docker or could grab the app environment from cli args // EnvironmentType is an enum that you can extend to add more values to $envType = new EnvironmentType(getenv('ENVIRONMENT')); $envFile = "/my/app/envs/.{$envType}.env"; // we can now create the app environment $env = Environment::createWithEnvFile($envType, $envFile); // tells you which environment you're in $env->is(EnvironmentType::DEVELOPMENT()); // true $env->is(EnvironmentType::PRODUCTION()); // false // tells you if a var exists $env->has('FOO'); // true // returns a value caster of a value that can then be called to get stricter types $env->get('FOO')->asArray(); $env->get('BAR')->asBoolean(); $env->get('BAR')->asInteger();
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-05-24