@@ -378,6 +378,58 @@ Symfony provides the following env var processors:
378
378
$container->setParameter('env(TRUSTED_HOSTS)', '10.0.0.1,10.0.0.2');
379
379
$framework->trustedHosts(env('TRUSTED_HOSTS')->csv());
380
380
};
381
+ ``env(shuffle:FOO) ``
382
+ Randomly shuffles values of ``FOO ``, which is an array.
383
+ Usable when combining with other processors, as array is a prerequisite.
384
+
385
+ .. configuration-block ::
386
+
387
+ .. code-block :: yaml
388
+
389
+ # config/packages/framework.yaml
390
+ parameters :
391
+ env(REDIS_NODES) : " 127.0.0.1:6380,127.0.0.1:6381"
392
+ services :
393
+ RedisCluster :
394
+ arguments : [null, "%env(shuffle:csv:REDIS_NODES)%"]
395
+
396
+ .. code-block :: xml
397
+
398
+ <!-- config/packages/framework.xml -->
399
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
400
+ <container xmlns =" http://symfony.com/schema/dic/services"
401
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
402
+ xmlns : framework =" http://symfony.com/schema/dic/symfony"
403
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
404
+ https://symfony.com/schema/dic/services/services-1.0.xsd
405
+ http://symfony.com/schema/dic/symfony
406
+ https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
407
+
408
+ <parameters >
409
+ <parameter key =" env(REDIS_NODES)" >redis://127.0.0.1:6380,redis://127.0.0.1:6381</parameter >
410
+ </parameters >
411
+
412
+ <services >
413
+ <service id =" RedisCluster" class =" RedisCluster" >
414
+ <argument >null</argument >
415
+ <argument >%env(shuffle:csv:REDIS_NODES)%</argument >
416
+ </service >
417
+ </services >
418
+ </container >
419
+
420
+ .. code-block :: php
421
+
422
+ // config/services.php
423
+ use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
424
+
425
+ return static function (ContainerConfigurator $configurator): void {
426
+ $container = $configurator->services()
427
+ ->set(\RedisCluster::class)->args([null, '%env(shuffle:csv:REDIS_NODES)%']);
428
+ };
429
+
430
+ .. versionadded :: 6.2
431
+
432
+ The ``env(shuffle:...) `` env var processor was introduced in Symfony 6.2.
381
433
382
434
``env(file:FOO) ``
383
435
Returns the contents of a file whose path is the value of the ``FOO `` env var:
0 commit comments