c0ntax / env-providers-bundle
一套扩展,使您能够更轻松地使用 Symfony .env 文件
0.1.1
2018-03-22 13:29 UTC
Requires
- php: >=7.1
- symfony/config: ^3.4|^4.0
- symfony/dependency-injection: ^3.4|^4.0
- symfony/dotenv: ^3.4|^4.0
- symfony/http-kernel: ^3.4|^4.0
- symfony/yaml: ^3.4|^4.0
Requires (Dev)
- pds/skeleton: ^1.0
- phpunit/phpunit: ^7.0
- symfony/framework-bundle: ^3.4|^4.0
- symfony/phpunit-bridge: ^3.4|^4.0
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']