定制 bckp/environment 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bckp/environment

最新稳定版本:v2.0.0

Composer 安装命令:

composer require bckp/environment

包简介

Simple class for getting environment in proper type with fallback

README 文档

README

Easy class for getting ENV values with casting and default value fallback. Great for frameworks like Nette.

Coverage Status Tests Downloads this Month Scrutinizer Code Quality Latest stable License

Installation

The best way to install honklegion/environment is using Composer:

$ composer require honklegion/environment

Example

imagine, you have set your ENV as follows:

FOO=false
BAR=1
KEYS=1|2|3

Lets see PHP code

use HonkLegion\Environment;

// Using getenv function:
var_dump(getenv('FOO')); // string(false)

// Using Environment function:
var_dump(Environment::Bool('foo')); //bool(false)

// But we can go even further:
var_dump(Environment::Bool('BAR')); //bool(true)
var_dump(Environment::Float('BAR')); //float(1.0)

// What about multi-values?
var_dump(Environment::array('KEYS', '|', Environment::String)); //array(3) [0 => '1', 1 => '2', 2 => '3'] - notice we have strings
var_dump(Environment::array('KEYS', '|', Environment::Int)); //array(3) [0 => 1, 1 => 2, 2 => 3] - notice we have int

// Default values? No problem!
var_dump(Environment::Bool('prod', true)); //bool(true) * even bin is not set

Development

This package is currently maintaining by these authors.

统计信息

  • 总下载量: 255
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-01