use Nowo\RuntimeEnvBundle\Service\RuntimeEnvBag;
final class SomeService
{
public function __construct(private readonly RuntimeEnvBag $runtimeEnv)
{
}
public function callExternalApi(): void
{
$token = $this->runtimeEnv->get('EXTERNAL_API_TOKEN');
if ($token === null) {
throw new \RuntimeException('EXTERNAL_API_TOKEN is not configured.');
}
// ...
}
}has(string $name): boolget(string $name, ?string $default = null): ?stringall(): array<string, string>— enabled variables only
{% if runtime_env_has('FEATURE_FLAG_X') %}
{{ runtime_env('FEATURE_FLAG_X') }}
{% endif %}Do not dump secret values into public HTML.
Open /_runtime_env (or your panel.path_prefix). Names must match ^[A-Z][A-Z0-9_]*$.
List view always masks values. Edit form shows the decrypted plaintext only to authorized admins.
Anything required to boot the kernel / connect to the DB / decrypt fields:
DATABASE_URL,APP_SECRET- DoctrineEncrypt secret key path / material
FRANKENPHP_MODE, ports, etc.
RuntimeEnvBag is tagged with kernel.reset. Between requests the in-memory map is cleared so values cannot leak across users/requests. After CRUD writes, the bag cache is invalidated immediately for the current process; other workers pick up changes on their next request (next reset + reload from DB).