定制 devcirclede/env-reader 二次开发

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

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

devcirclede/env-reader

最新稳定版本:0.4.3

Composer 安装命令:

composer create-project devcirclede/env-reader

包简介

Simple Env Reader/Parser for PHP

README 文档

README

workflow

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固