tristankechlo/simple-dotenv 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

tristankechlo/simple-dotenv

最新稳定版本:1.0.0

Composer 安装命令:

composer require tristankechlo/simple-dotenv

包简介

simple library to parse .env files

README 文档

README

small parser for .env files

normal parsing

# .env file
KEY1="This is a string"
KEY2=234
KEY3=4.5
KEY4=TRUE
KEY5=OFF
# php file
use TK\Dotenv\Dotenv;

$content = file_get_contents("./.env");
$actual = Dotenv::parse($content);
# output
$actual = [
    "KEY1" => "This is a string",
    "KEY2" => "234",
    "KEY3" => "4.5",
    "KEY4" => "TRUE",
    "KEY5" => "OFF",
];

parsing with conversion

# .env file
KEY1="This is a string"
KEY2=234
KEY3=4.5
KEY4=TRUE
KEY5=OFF
# php file
use TK\Dotenv\Dotenv;

$content = file_get_contents("./.env");
$actual = Dotenv::parse($content, true);
# output
$actual = [
    "KEY1" => "This is a string",
    "KEY2" => 234,
    "KEY3" => 4.5,
    "KEY4" => true,
    "KEY5" => false,
];

conversion

The parse can convert some values to php primitive types, otherwise all values are string.

booleans

these values will be converted to booleans (case insensitive):

  • truthy_values = ['true', 'yes', 'on']
  • falsy_values = ['false', 'no', 'off']

numbers

these values will be converted to numbers:

  • integers (e.g. 3 or 23424)
  • floats (e.g. 5.76 or 43234.3453)
  • hexadezimal only with prefix 0x (e.g. 0xa0 to 160)
  • binary only with prefix 0b (e.g. 0b110011 to 51)
  • octal only with prefix 0o (e.g. 0o77 to 63)

null

these values will be converted to null (case insensitive):

  • null
  • none

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-20