c0ntax/env-providers-bundle

一套扩展,使您能够更轻松地使用 Symfony .env 文件

安装: 3

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 0

开放问题: 0

类型:symfony-bundle

0.1.1 2018-03-22 13:29 UTC

This package is auto-updated.

Last update: 2024-09-29 04:36:55 UTC


README

一些额外的环境提供者,让使用 Symfony 3+ .env 文件不那么痛苦

简介

<rant type="personal">我非常偏好旧的 parameters.yml 方法,因为它更灵活,但 Symfony 已经决定转向 dotenv,所以...</rant> 此包添加了解析 dotenv 变量的 '缺失' 方法,这样您就不会那么讨厌它了。

安装

您应该知道了

composer require c0ntax/env-providers-bundle

如果您不使用 Flex,别忘了将以下内容添加到您的 Kernel 中

    public function registerBundles()
    {
        $bundles = [
            // ...
            new C0ntax\EnvProvidersBundle\C0ntaxEnvProvidersBundle(),
            // ...
        ];
    }

配置

目前配置简单,您可以添加以下内容

c0ntax_env_providers:
    array:
        return_null_if_empty: true # If the env variable = '' then return a null instead of an empty array

用法

在您的 .env 文件中

ENV_VAR=this,that, other

然后在您的配置中

parameters:
    array_thing: '%env(array:ENV_VAR)%'

嗯,就是这样。 array_thing 现在等于 ['this', 'that', 'other']