Environment
in package
The process environment, plus a `.env` file, read once and shared.
Every connector needs settings of its own, and each one reading the file itself would mean parsing it several times and — worse — disagreeing about precedence. So the app loads this once and hands it to whatever needs it.
The process environment wins over the file, so a container can override a setting without the image being rebuilt or the file edited.
Secrets only ever come from here, never from the JSON store — that is runtime state a server admin edits through chat, and it should be safe to read, back up, or paste into an issue.
Tags
Table of Contents
Properties
Methods
- fromArray() : self
- For tests, and for anything that already has its settings in hand.
- get() : string|null
- A setting, or `null` when it is absent or empty.
- has() : bool
- Whether every one of these is set, for deciding whether to install a connector at all.
- load() : self
- Reads `$path` if it is there, and falls back to the process environment.
- or() : string
- A setting, or `$default`.
- require() : string
- A setting, or a thrown explanation naming what is missing.
- __construct() : mixed
Properties
$path read-only
public
string
$path
$file read-only
private
array<string|int, mixed>
$file
Methods
fromArray()
For tests, and for anything that already has its settings in hand.
public
static fromArray(array<string|int, mixed> $values[, string $path = '' ]) : self
Parameters
- $values : array<string|int, mixed>
- $path : string = ''
Return values
selfget()
A setting, or `null` when it is absent or empty.
public
get(string $key) : string|null
Parameters
- $key : string
Return values
string|nullhas()
Whether every one of these is set, for deciding whether to install a connector at all.
public
has(string ...$keys) : bool
Parameters
- $keys : string
Return values
boolload()
Reads `$path` if it is there, and falls back to the process environment.
public
static load(string $path) : self
Parameters
- $path : string
Return values
selfor()
A setting, or `$default`.
public
or(string $key, string $default) : string
Parameters
- $key : string
- $default : string
Return values
stringrequire()
A setting, or a thrown explanation naming what is missing.
public
require(string $key) : string
Parameters
- $key : string
Tags
Return values
string__construct()
private
__construct(array<string, string> $file, string $path) : mixed
Parameters
- $file : array<string, string>
- $path : string