定制 sirix/sirix-env 二次开发

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

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

sirix/sirix-env

最新稳定版本:1.0.0

Composer 安装命令:

composer require sirix/sirix-env

包简介

A helper function to retrieve environment variables with type casting

README 文档

README

A helper function to retrieve environment variables with type casting.

Installation

Install this tool using composer.

composer require sirix/sirix-env

Usage

This library provides a global env function that allows you to retrieve environment variables and automatically cast them to their appropriate PHP types.

Basic Usage

use function Sirix\Env\env;

$value = env('MY_VAR');
$defaultValue = env('NON_EXISTENT', 'default');

Type Casting

The env function automatically casts string values to the following types:

Value PHP Type Result
'true', '(true)' boolean true
'false', '(false)' boolean false
'null', '(null)' null null
'empty', '(empty)' string ''
'123', '1.23' integer / float 123 / 1.23
Other values string Original string (trimmed)

Static usage

If you prefer not to use the global function, you can use the EnvParser class directly:

use Sirix\Env\EnvParser;

$value = EnvParser::parse('true'); // true

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04