Is it possible to define array constants from Trellis to Bedrock?

The Goal:
To have an array constant on Bedrock:

define('ARRAY_OF_SECRETS', [

Is it possible to:

  1. save these passwords in Trellis’ ansible vault
  2. “render” the passwords as environment variables
  3. “build” the PHP constant

I’ve tried adding variables in env inside wordpress_sites. However, it seems array is not supported.


It’s not possible unfortunately. We use .env which are supposed to be just environment variables which basically only supports strings (in reality it’s a bit more).

For anyone who facing the same issue:

$prefix = 'password_';

$index = 1;

while (! empty(Env::get($prefix . $index))) {
    $secrets[] = (string) Env::get($prefix . $index);

define('ARRAY_OF_SECRETS', $value);

Real life example:

1 Like