定制 deinternetjongens/env 二次开发

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

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

deinternetjongens/env

Composer 安装命令:

composer require deinternetjongens/env

包简介

Simple library to consume environment variables

关键字:

README 文档

README

Build Status Scrutinizer Code Quality

Simple library to get environment variables converted to simple types.

Installation

This package is installable and autoloadable via Composer as oscarotero/env.

$ composer require deinternetjongens/env

Example

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

// Using Env:
var_dump(Env::get('FOO')); //bool(false)

Available conversions:

  • "false" is converted to boolean false
  • "true" is converted to boolean true
  • "null" is converted to null
  • If the string contains only numbers is converted to an integer
  • If the string has quotes, remove them

To configure the conversion, you can use the following constants (all enabled by default):

  • Env::CONVERT_BOOL To convert boolean values
  • Env::CONVERT_NULL To convert null values
  • Env::CONVERT_INT To convert integer values
  • Env::STRIP_QUOTES To remove the quotes of the strings
//Convert booleans and null, but not integers or strip quotes
Env::$options = Env::CONVERT_BOOL | Env::CONVERT_NULL;

Default value

By default, if the value does not exits, returns null, but you can change for any other value:

Env::$default = false;

The env() function

If you don't want to complicate with classes and namespaces, you can use the env() function, like in Laravel or other libraries:

Env::init(); //expose the function to globals

//now you can use it

var_dump(env('FOO'));

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-05-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固