php-cooper

Application

Table of Contents

Classes

Cache
Backs `Cooper::loadFile()`'s default caching -- the Elixir original's `Cooper.Cache`. It caches the *pre-resolve* tree (parse, imports, loops, merge) per entry file and root, and reuses it as long as every file that contributed -- the entry file and every file it transitively imports -- still has the modification time it had when cached, and every import pattern (`import "parts/*.casc"`, braces too) still matches the files it matched then -- a file added where an import looks, or removed from there, is a change like an edited one.
CacheEvent
What a `Cache::listen()` listener receives -- the PHP counterpart of the Elixir original's `[:cooper, :cache, :file_changed]` and `[:cooper, :cache, :env_changed]` telemetry events.
ConformanceAdapter
This implementation's adapter for the Cooper Conformance Suite: a JSON request in, a JSON answer out (`php bin/cooper-conformance REQUEST ANSWER`). The PHP twin of the Elixir reference's `Cooper.Conformance`, with the same behaviour and the same JSON.
Cooper
Loads CASC config files (see `casc/CASC.md`) into native PHP values.
CooperError
The one exception type every `cooper` failure mode throws -- lexing, parsing, literal validation, loop expansion, imports, merging, reference resolution, and `.env` loading alike -- so a caller only ever needs to catch one type.
Dotenv
Builds the environment `${...}` references (CASC.md §7.2) read -- the Elixir original's `Cooper.Dotenv`. `Cooper` calls it on every load, cached or not, so `${...}` values are always current.
EnvReference
One `${NAME}` written as a value, as the `envValue` load option sees it (see `Cooper`): the name it reads and everything written around it.
ImportGlob
One filesystem import's expansion: the `$pattern` it named (braces and wildcards, CASC.md §5.1, after `${NAME}` interpolation), the `$root` it was expanded under, and the `$files` it matched then.
LiteralTag
A consumer tag that takes **only a string literal written in the document**, registered under the `tags` option like any other:
LoadTrace
What `Cooper::loadFileTraced()` returns: the loaded config, together with everything that load depended on.
CooperAtom
A CASC atom (CASC.md §6.4) -- `level = info`, `level = :info`.
CooperBytes
A CASC byte size (CASC.md §6.9) -- `512MiB`, `10GB`, or `!bytes("512MiB")` -- as a whole number of bytes, matching the Elixir original's `{:bytes, count}`.
CooperDate
A CASC local date (CASC.md §6.6) -- `1979-05-27` -- with no time or zone attached, matching Elixir's `Date`. PHP has no date-only type, and a `DateTimeImmutable` at midnight would invent a time and a zone the document never stated; `toDateTimeImmutable()` makes that choice explicit when it is wanted.
CooperDateTime
A CASC offset date-time (CASC.md §6.6) -- `1979-05-27T07:32:00Z`, `...00.120+02:00` -- matching Elixir's `DateTime`: an instant at microsecond resolution, normalized to UTC, together with how many fractional digits were written (`$precision`, at most 6).
CooperDuration
A CASC duration (CASC.md §6.8) -- `500ms`, `1h30m`, or `!duration("5m")` -- as a whole number of nanoseconds, the same base unit the Elixir original's `{:duration, nanoseconds}` uses.
CooperInteger
A CASC integer (CASC.md §6.3) too large for PHP's 64-bit `int` -- `12345678901234567890`, or `!int("...")` of one -- kept exactly, as the Elixir original's arbitrary-precision integers are.
CooperIPv4
A parsed IPv4 address, with an optional CIDR prefix (CASC.md §6.7 -- `127.0.0.1` or `127.0.0.1/32`). The constructor validates, and it is the same validation a bare literal goes through at load time -- an out-of-range octet or prefix is an error, never a silently accepted garbage value.
CooperIPv6
A parsed IPv6 address, with an optional CIDR prefix (CASC.md §6.7 -- `::1` or `::1/128`). The constructor validates, and it is the same validation a bare literal goes through at load time.
CooperLocalDateTime
A CASC local date-time (CASC.md §6.6) -- `1979-05-27T07:32:00` with no offset -- matching Elixir's `NaiveDateTime`. An *offset* date-time (`...Z`, `...+02:00`) is a real instant and loads as a `CooperDateTime` instead; this one names a wall-clock reading in no particular zone, which `toDateTimeImmutable()` lets the caller place.
CooperSecret
Wraps a secret value (CASC.md §4.3's `*key`-prefixed keys) in the result `Cooper::loadFile()`/`Cooper::loadString()` return, so it never leaks by accident: string conversion, `json_encode()`, `var_dump()`, and `print_r()` all redact regardless of the wrapped value. Reach the real value deliberately with `reveal()` -- the wrapping is only ever a display-time concern, never a barrier to the developer's own use of the value.
CooperTime
A CASC local time of day (CASC.md §6.6) -- `07:32:00`, optionally with fractional seconds -- matching Elixir's `Time`: microsecond resolution, and the number of fractional digits written (`$precision`, at most 6) kept so `07:32:00.5` renders back as written rather than as `07:32:00.500000`.
CooperTuple
A CASC tuple (CASC.md §6.11) -- `office_location = (52.5200, 13.4050)`.
Values
Structural equality over loaded values -- what `-key = [...]` (CASC.md §8.4) removes by, and what the value classes' own `equals()` methods build on.
On this page

Search results