Index

Credentials

MMO\admin\helpers · 1 symbol · generated 5 Oct 2026

class

Credentials

Credentials.php:32

The secrets a deployment needs, read from a file in the project that git never sees.

class MMO\admin\helpers\Credentials
Namespace
MMO\admin\helpers
This exists because of a specific, real failure: the previous pipeline kept the production ssh password in `scripts/bootstrap.php`, a tracked file, which put it on 31 branches and in the history of every clone ever made. `.gitignore` discipline alone would not have stopped it -- it is a convention, and conventions get skipped -- so the rule here is structural rather than procedural: this file is REFUSED if git would commit it ([`assertIgnored`](https://mcp.mmoframework.fr/documentation/mmo.admin/php/helpers/Credentials.md#credentials-assertignored)). [`Server`](https://mcp.mmoframework.fr/documentation/mmo.admin/php/entities/Server.md#server) declares only an auth *method*; the value behind it is resolved, at use time, from here. The file is per-project and per-machine, at [`FILENAME`](https://mcp.mmoframework.fr/documentation/mmo.admin/php/helpers/Credentials.md#credentials-filename) beside `deploy.json`: ```json {"servers": { "ovh1": {"password": "..."}, "ovh2": {"privateKey": "~/.ssh/id_ed25519", "publicKey": "~/.ssh/id_ed25519.pub", "passphrase": "..."} }} ``` Nobody else may read it (mode 0600), and git must ignore it. Either one failing is refused outright rather than warned about, because a warning on a fleet tool is a warning nobody reads.
$credentials = new Credentials(Credentials::DefaultFilename('/var/www/my.oviepro')); $credentials->get('ovh1', 'password');

Index

FILENAMEwhere a project keeps its deployment secrets: at its root, beside deploy.json.
data
filename
loaded
assertIgnored($filename)Refuse a credentials file git would commit.
assertPrivate($filename)Refuse a credentials file anyone else on the machine can read.
debugName()
DefaultFilename($root) staticWhere a project's credentials live by default: FILENAME, in the project.
FromArray($servers) static
get($server, $key, $required)
getFilename()
has($server, $key)
isLoaded()
servers()
__construct($filename)

Constants1

FILENAME

where a project keeps its deployment secrets: at its root, beside deploy.json. init's .gitignore ignores it.

const FILENAME = 'deploy.credentials.json'

Properties3

data

protected array $data = []
Type
array

filename

protected ?string $filename = null
Type
null | string

loaded

protected bool $loaded = false
Type
bool

Methods11

assertIgnored($filename)

Credentials.php:164

Refuse a credentials file git would commit.

protected function assertIgnored(string $filename): voidThe file lives in the project, so all that stands between it and the history of every clone is an ignore rule -- and an ignore rule is exactly what is missing the day it matters: a `.gitignore` older than the file, a pattern someone tidied away, a `git add -f`. So git is asked, every time the file is read. A TRACKED file is refused even when a rule matches it, since ignoring never untracks anything, and with a different remedy: what it holds may already be in a commit, and only changing the secrets undoes that. Outside a repository, or on a machine without git, there is nothing to commit it to.
$filenamestring
returnsvoid
throws

assertPrivate($filename)

Credentials.php:134

Refuse a credentials file anyone else on the machine can read.

protected function assertPrivate(string $filename): void
$filenamestring
returnsvoid
throws

DefaultFilename($root)

staticCredentials.php:87

Where a project's credentials live by default: FILENAME, in the project.

static function DefaultFilename(string $root): string
$rootstringthe project's folder -- the one holding deploy.json.
returnsstring

FromArray($servers)

staticCredentials.php:76
static function FromArray(array $servers): static
$serversarrayserver name => [key => value]: what setup is about to write, before it is written.
returnsstaticcredentials read from nowhere: nothing to check, as nothing is in a file.

get($server, $key, $required)

Credentials.php:112
function get(string $server, string $key, bool $required = false): ?string
$serverstring
$keystringpassword, privateKey, publicKey, passphrase.
$required = falsebool
returnsnull | string
throwswhen $required and there is nothing to return.

isLoaded()

Credentials.php:95
function isLoaded(): bool
returnsboolwhether a credentials file was actually loaded.

__construct($filename)

Credentials.php:50
function __construct(?string $filename = null)
$filename = nullnull | stringresolved through filename. A missing file is NOT an error: a project whose servers all authenticate through the ssh agent needs no credentials file at all.
throwsif the file exists but git would commit it, someone else can read it, or it is not JSON.