CooperRuntime
extends SymfonyRuntime
in package
Symfony's runtime, with Cooper reading the `.env` files: named in the application's `composer.json` as `extra.runtime.class`.
Before the kernel exists, Cooper's Dotenv::export() puts what the
.env files say into the process environment -- .env,
.env.<COOPER_ENV>, .env.local, from the project directory, never
over a variable the real environment already has -- so %env(...)%
placeholders, $_SERVER['APP_DEBUG'] and anything else reading the
environment find it. Symfony's own .env loading is always off: two
loaders with two sets of rules would disagree about which file wins.
The environment's name
Symfony's environments are Cooper's: dev, test, prod. Whichever
is named first decides both:
- the runtime's
envoption, or--env/-eon the command line -- Cooper reads that environment's.env.<env>; - a real
APP_ENVorCOOPER_ENV-- Cooper's fallback readsAPP_ENVwhenCOOPER_ENVis unset; COOPER_ENVorAPP_ENVfrom the.envfiles;dev.
APP_ENV, when nothing set it, is set to the COOPER_ENV so found.
APP_DEBUG is read as Symfony reads it, from wherever it now is --
the real environment or a .env file -- and is on outside prod
when neither sets it.
Every other option is Symfony's own (project_dir, prod_envs,
env_var_name, debug_var_name, ...); dotenv_path,
dotenv_overload and dotenv_extra_paths mean nothing here --
Cooper's .env layering is fixed (see JOetjen\Cooper\Dotenv).
Table of Contents
Methods
- __construct() : mixed
- inEnvironment() : bool
- Whether `$name` is set in the process environment, where Symfony looks for it.
- namedEnvironment() : string|null
- The environment the runtime is told to run, before any variable is consulted: its `env` option, else `--env`/`-e` on a command line -- the two places Symfony's runtime itself looks first.
Methods
__construct()
public
__construct([array<string, mixed> $options = [] ]) : mixed
Parameters
- $options : array<string, mixed> = []
-
Symfony's runtime options;
disable_dotenvis always set
Tags
inEnvironment()
Whether `$name` is set in the process environment, where Symfony looks for it.
private
static inEnvironment(string $name) : bool
Parameters
- $name : string
Return values
boolnamedEnvironment()
The environment the runtime is told to run, before any variable is consulted: its `env` option, else `--env`/`-e` on a command line -- the two places Symfony's runtime itself looks first.
private
static namedEnvironment(array<string, mixed> $options) : string|null
Parameters
- $options : array<string, mixed>