devcirclede/env-reader
最新稳定版本:0.4.3
Composer 安装命令:
composer create-project devcirclede/env-reader
包简介
Simple Env Reader/Parser for PHP
README 文档
README
EnvReader
PHP Environment Reader
Simple Environment Reader which can parse the Value to a specific type. It tries to find the Value in $_ENV, $_SERVER and via getenv. The logic is leaned on the EnvVarProcessor from Symfony.
Installation
composer require devcirclede/env-reader
Supported Types
Actual included Types are:
- integer
- float
- string
- boolean
- array
- json
You can add your own Type by creating a class which implements the TypeInterface.
Example:
<?php declare(strict_types=1); namespace Company\EnvTypes; use DevCircleDe\EnvReader\Types\TypeInterface; class CustomType implements TypeInterface { public function getName(): string { return 'custom'; } public function convert(string $value): mixed { // convert the value to custom type return $value; } }
Usage of the CustomType:
<?php use Company\EnvTypes\CustomType; use DevCircleDe\EnvReader\EnvParser; $envParser = EnvParser::getInstance(); // add custom type $envParser->getCollection()->addItem(new CustomType()); // read Env $var = $envParser->parse('FOO', 'custom_type');
统计信息
- 总下载量: 78
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-03-08