MMOframework
Pourquoi l'IA Playground Bibliothèques Développeurs Agence
FR EN
Créer un projet en direct
Index

CommandJournal

MMO\admin\helpers · 1 symbole · générée le 30 Nov 2026

class

CommandJournal

CommandJournal.php:28

The journal of the privileged utilities (ISO 27001 A.8.18, A.8.15): every command of the application's php admin.php that changes something, run where the configuration says it is production (MMO_MODE, $modes), is written down -- the command and its arguments (a secret's value masked), who ran it (the system user, and SUDO_USER), on which host and folder, the approval it names (--approval=<ticket>), when, and how it ended.

class MMO\admin\helpers\CommandJournal
Espace de noms
MMO\admin\helpers
Which commands only read is what each one declares: its `#[Command]`'s info `readOnly` (true or false), else a summary or a description saying `read only` (`... (read only)`, `Read only: nothing is changed.`: the convention of my.oviepro's admin.php), one of [`$readOnly`](https://mmoframework.fr/fr/documentation/mmo.admin/php/helpers/CommandJournal.md#commandjournal-readonly), or any command run with `--dry-run` or `--help`. Every other command is taken for one that changes something: forgetting to declare a command journals it, it never hides it. Off by default; an application switches it on in its configuration: "MMO\\admin\\helpers\\CommandJournal": {"enabled": true, "file": "{db}/admin-commands.jsonl"} Two lines per command, `started` then `ended` (the same `id`), so a command killed half way still shows.
CommandJournal::IsReadOnly(['data-guard', 'compare'], ['--dry-run' => false], 'read only: compare ...'); // true CommandJournal::Mask(['--uri=mongodb://u:p@h', '--database=acme']); // ['--uri=***', '--database=acme']

Index

atShutdown
enabled
entry
file
modes
readOnly
requireApproval
secrets
debugName()
end($code, $error, $seconds, $status)Write the command's end: its outcome.
getFilename()
infos($route)
IsReadOnly($words, $options, $infos, $readOnly) static
Mask($argv, $secrets) static
Split($argv) static
start($route, $argv)
User() static
Watch($route) staticThe listener mmo.admin's bootstrap connects to every route: on the command line, in a mode of $modes, a command that changes something is journaled.
write($line)
__construct($config)

Propriétés8

atShutdown

bool $atShutdown = true
Type
bool

enabled

bool $enabled = false
Type
bool

entry

protected ?array $entry = null
Type
null | array

file

string $file = '{root}/logs/admin-commands.jsonl'
Type
string

modes

array $modes = ['prod']
Type
array

readOnly

array $readOnly = […11 items]
Type
array

requireApproval

bool $requireApproval = false
Type
bool

secrets

array $secrets = […9 items]
Type
array

Méthodes12

end($code, $error, $seconds, $status)

CommandJournal.php:116

Write the command's end: its outcome.

function end( int $code, ?string $error = null, ?float $seconds = null, ?int $status = null ): void
$codeint
$error = nullnull | string
$seconds = nullnull | float
$status = nullnull | int
retournevoid

infos($route)

CommandJournal.php:138
protected function infos(MMO\core\server\Route $route): array
$routeRoute
retournearraythe infos of the commands the route runs (their #[Command]s): summary, description, readOnly

IsReadOnly($words, $options, $infos, $readOnly)

staticCommandJournal.php:179
static function IsReadOnly(array $words, array $options, array $infos, array $readOnly = []): bool
$wordsarraythe command's
$optionsarrayits options
$infosarraywhat its #[Command]s say of it: readOnly (true or false: the declaration), else a summary starting with read only or ending with (read only), a description starting with read only or holding a paragraph that does (a string is a description)
$readOnly = []arraythe commands declared reading only besides
retourneboolwhether the command only reads: every one of its commands says so

Mask($argv, $secrets)

staticCommandJournal.php:202
static function Mask( array $argv, array $secrets = ['password', 'secret', 'token', 'key', 'uri', 'dsn'] ): array
$argvarray
$secrets = ['password', 'secret', 'token', 'key', 'uri', 'dsn']array
retournearray$argv, the value of an option whose name holds one of $secrets replaced by ***

Split($argv)

staticCommandJournal.php:156
static function Split(array $argv): array
$argvarray
retournearraylist<string>, 1: array<string, string|true>} the words before the first option, and the options (--name => value, true for a flag)

start($route, $argv)

CommandJournal.php:81
function start(MMO\core\server\Route $route, array $argv): ?array
$routeRoutethe command's
$argvarrayits words, after the script's name
retournenull | arraythe entry written, null for a command that only reads

Watch($route)

staticCommandJournal.php:67

The listener mmo.admin's bootstrap connects to every route: on the command line, in a mode of $modes, a command that changes something is journaled.

static function Watch(MMO\core\server\Route $route): void
$routeRoute
retournevoid