Application
Table of Contents
Classes
- Commented
- A map entry's value with a comment `Writer` puts on the lines above its key -- a `# was: env("APP_URL")` note for a migrated setting, say.
- MapValue
- An array `Writer` writes as a map -- a block -- whatever its shape: the one way to say that an empty array is an empty map (`logger {}`) rather than an empty list (`logger = []`), or that an array keyed `0`, `1`, ... is a map keyed `"0"`, `"1"`, .... A PHP array cannot say which it is, and both load back as the same array, so `Writer` reads a bare one as a list. The difference is in what the document means (CASC.md §5.4): written over a map that is already there -- in an overlay, say -- `{}` merges and leaves it as it is, where `[]` replaces it.
- Raw
- A value that is already CASC source, which `Writer` writes exactly as given instead of as data: an environment reference (`${DB_HOST:"127.0.0.1"}`), a tagged value (`!int(${PORT})`, `!module("Foo.Bar")`), a duration (`5m`), an atom (`info`) -- anything a plain PHP value cannot say.
- Secret
- A map entry's value whose key `Writer` marks secret (CASC.md §4.3): `*password = "..."`, or `*database { ... }` for a block, every value in which then loads as a secret. The value itself is written as if it were not wrapped -- a scalar, a `Raw`, a list, a block.
- Writer
- Writes a PHP value tree as a CASC document (`casc/CASC.md` in `joetjen/cooper`) that loads back as the same values -- the shared writer behind every generated `.casc` file (a framework's existing configuration converted, a scaffold).
- Cli
- `vendor/bin/cooper-config`: the `cooper:*` commands (see `JOetjen\CooperConfig\Command`) as a standalone Symfony Console application, for a project with no `bin/console` or artisan to register them with.
- CacheClearCommand
- `cooper:cache:clear [--root=DIR] [--cache-dir=DIR]`: removes every compiled configuration file. Part of a deploy.
- CheckCommand
- `cooper:check [--root=DIR] [--path=FILE]`: loads the configuration as `Config::load()` would and reports it -- the document, its top-level keys; exit status 1 and the error on failure.
- InitCommand
- `cooper:init [--root=DIR]`: writes `config/config.casc` and one directory per environment (`config/dev/`, `config/test/`, `config/prod/`), each holding one `.casc` so the document's `import "${COOPER_ENV}/*.casc"` matches. Refuses to overwrite anything: one existing file and nothing is written.
- CompiledCache
- The compiled cache: a loaded, converted configuration written as a PHP file, so the next request includes it instead of parsing the document.
- Config
- The application's configuration: a CASC document loaded with Cooper, once, at startup, and read through this class afterwards -- the PHP counterpart of the Elixir `cooper_config` and the Praxis `cooper_prx`.
- ConfigError
- The configuration could not be loaded: an explicitly given file is missing, Cooper refused the document, or what it loaded could not be converted (a duration that is not whole milliseconds, a refused `cooper-secrets` policy).
- ConversionError
- Cooper loaded the document, but it cannot become application configuration: a duration that is not a whole number of milliseconds, or a `cooper-secrets` policy that is misplaced, unknown, or names a class that cannot wrap a secret. `Config::load()` reports it as a `ConfigError`; `Convert::toAppConfig()` throws it directly.
- Convert
- Turns what `Cooper` loaded into application configuration -- the counterpart of the Elixir `CooperConfig.Convert` and the Praxis `cooper.config/as-app-config`.
- LoadReport
- What the last `Config::load()` did: which document, whether it was there, and whether the compiled cache served or stored it. For diagnostics (`cooper-config check`), never needed to read the configuration itself.
- MissingKeyError
- `Config::require()` found nothing at the path it was given.
- NotLoadedError
- The configuration was read before it was loaded.
- ProjectRoot
- Where the application lives: the directory `config/config.casc` and `var/cache/cooper-config/` are found under by default.
Functions
- cooper_config() : mixed
- The loaded configuration, or the value at `$path` in it: the global shorthand for `Config::all()`/`Config::get()`. Not `config()`, which Laravel owns.
Functions
cooper_config()
The loaded configuration, or the value at `$path` in it: the global shorthand for `Config::all()`/`Config::get()`. Not `config()`, which Laravel owns.
cooper_config([string|array<int, string|int>|null $path = null ][, mixed $default = null ]) : mixed
Parameters
- $path : string|array<int, string|int>|null = null
-
a dotted path or a list of segments; null for the whole configuration
- $default : mixed = null
-
what to return when
$pathleads nowhere
Tags
Return values
mixed —the value, or $default