MMOframework
Why AI Playground Libraries Developers Agency
FR EN
Build a project live
Index

ProjectRuns

MMO\admin\monitoring · 1 symbol · generated 30 Nov 2026

class

ProjectRuns

ProjectRuns.php:29

What a hub may run on its project, checked out on this machine (LocalProject): a closed list (RUNS), each written here as the project's own command line -- its tests, php scripts/admin.php <command> for its deployments, git for its branch. The page and php hub.php run only name a run and pick its targets: they never send a command, but to cmd, admin.php's own: the command typed is run on the sites named, as its --exec=, once confirmed.

class MMO\admin\monitoring\ProjectRuns
Namespace
MMO\admin\monitoring
Every run that changes something is a dry run unless asked otherwise ([`options`](https://mmoframework.fr/en/documentation/mmo.admin/php/monitoring/ProjectRuns.md#projectruns-options)); one that deploys asks the targets' names typed again (`confirm`), which becomes admin.php's `--i-understand`. What a run printed and how it ended is kept in the hub's data (`{data}/project/{run}.json`): the page shows the last one without running it again. A run of [`BATCHED`](https://mmoframework.fr/en/documentation/mmo.admin/php/monitoring/ProjectRuns.md#projectruns-batched) is a batch: each site its own process (`--targets=<one>`), several at a time -- `concurrency`, by default what the servers can take ([`concurrency`](https://mmoframework.fr/en/documentation/mmo.admin/php/monitoring/ProjectRuns.md#projectruns-concurrency)) --, one site failing stopping none of the others, each one's outcome kept (`{data}/project/targets/{site}/{run}.json`) and said as it changes (the progress's `targets`). One that changes the sites tries the first one alone (`canary`), and the others only once it passed; a release or a ship builds every site's artifact first, in one pass, so that no two builds run at once.
$runs = new ProjectRuns(LocalProject::Of($hub)); $result = $runs->execute('tests', $runs->options('tests', []), fn($line) => print("$line\n")); $runs->last('tests')['ok']; // true

Index

BACKUPSthe runs that change a site's backups: applied, each site's backups are read again after it (BackupInventory)
BATCHEDthe runs made of one process per site (executeBatch): what acts on each site alone
DATAthe runs that move a site's data (admin.php's data-*): applied, each site's status is read again after it
DUMPa dump --file= names: a file name of a backup folder, no path
MAX_CONCURRENCYthe most sites a batch runs at once, whatever is asked
PARTSwhat version --part= increases
PREBUILTthe batches that build every site's artifact first, in one pass: a build shares the libraries' cached phars
RELEASEa release name --to= names: what admin.php's releases are called
REPORTEDthe runs each result of which is also kept as a dated report ({data}/project/reports/{run}/{date}.json): evidence
RUNSrun => what it is: label, changes (whether it changes something: a dry run by default, then confirmed; on sites, their names typed again unless confirm is false: what writes only here, or add…
SIDESa data run's side that wins what both changed differently (admin.php's --prefer=)
WHEREwhere a backup run deletes: a site's server, this machine, both (admin.php's --where=)
project
audit($say, $result)The project's third-party dependencies against the known vulnerabilities: composer audit when it has a composer.json, npm audit when it has a package.json (each when its tool is there).
concurrency($names)How many sites a batch runs at once by default: what each server can take -- its free processors, from its last reading (cpu.count, load.perCpu), two per site, one to four; one when it was neve…
confirmation($typed)
debugName()
decrypt($file, $config, $say)
domains($say, $result)When each domain of the sites expires: their registry's RDAP answer (rdap.org finds it), one question a domain.
drift($say, $result)For each site asked (every one when none is), the keys of its live configs/prod.json against the same file at its ref: keys only, never their values -- they are its secrets.
dumps($target)A site's dumps, to restore one (restore's file): those of its server's backup folder, newest first, then those of this machine's backups (a backup fetched here), which admin.php uploads before …
execute($run, $options, $say, $progress, $stop)Run a run's steps one after the other, saying each line they print; stop at the first that fails, or when asked.
executeBatch($run, $options, $say, $progress, $stop)A run of BATCHED: each site its own process, several at a time, the others going on when one fails.
flushSite($site, $say)Say what a site printed last, without its end of line.
getFolder()
getProject()
i18n($say, $result)
IsChatter($line) static
keepBackups($name, $json, $code, $result, $say)Keep what backups -m read of a site (BackupInventory): unknown with why when it was not read.
keepDataStatus($name, $json, $code, $result, $say)Keep what data-status -m read of a site (SyncStatus): unknown with why when it was not read.
keepTypes($name, $json, $code, $result, $say)Keep what section-types -m read of a site (TypeOverrideStatus): unknown with why when it was not read.
Keys($data, $prefix) static
last($run)
lastOf($target, $run)
lastSuccess($run)
lint($say)
LocalCpus() static
options($run, $options)The options of a run, checked: nothing but what this class knows reaches a command line.
packageFolder($package)
php()
phpstanSteps()
phpunit()
Plain($line) static
process($command, $cwd, $say, $stop, $capture)
reports($run)
restoreChecks($commands, $values, $say)The project's checks of a restored dump: each a command line of the hub's restoreTest.checks, its placeholders replaced (each value quoted), run in the project's folder.
restoreTest($say, $result)Whether a backup restores (ISO 27001 A.8.13): the newest dump of the site asked (or of any site) among the project's local dumps (what backup --fetch brings: .mongo, or .mongo.age encrypted o…
runSites($run, $options, $names, $total, $servers, $result, $states, $say, $report, $stop)Run some sites of a batch, each its own process: at most $total at once, and at most a server's slots on it.
save($run, $result)Keep a run's result: the last one of each run, and a dated report of those of REPORTED.
saveTarget($target, $run, $record)Keep one site's outcome of a batch: the last of each run, per site, which another batch of other sites leaves as it is.
sets($target)A site's backup sets (BackupSets): from its server's backups and this machine's, newest first.
siteLine($site, $name, $type, $line, $say)One line a site printed: its json kept (data-status, section-types), the framework's chatter left out, the rest said and kept.
startSite($run, $options, $name, $server, $say, $before, $code)
steps($run, $options)The steps of a run: each a command line, run in a folder; or call, run in this process.
testsStep()
__construct($project)

Constants12

BACKUPS

the runs that change a site's backups: applied, each site's backups are read again after it (BackupInventory)

const BACKUPS = ['backup', 'backup-delete', 'backup-prune', 'backup-fetch']

BATCHED

the runs made of one process per site (executeBatch): what acts on each site alone

const BATCHED = […26 items]

DATA

the runs that move a site's data (admin.php's data-*): applied, each site's status is read again after it

const DATA = ['data-pull', 'data-push', 'data-merge']

DUMP

a dump --file= names: a file name of a backup folder, no path

const DUMP = '/^[A-Za-z0-9][A-Za-z0-9._-]{0,160}$/'

MAX_CONCURRENCY

the most sites a batch runs at once, whatever is asked

const MAX_CONCURRENCY = 16

PARTS

what version --part= increases

const PARTS = ['patch', 'minor', 'major']

PREBUILT

the batches that build every site's artifact first, in one pass: a build shares the libraries' cached phars

const PREBUILT = ['release', 'ship']

RELEASE

a release name --to= names: what admin.php's releases are called

const RELEASE = '/^[A-Za-z0-9][A-Za-z0-9._-]{0,80}$/'

REPORTED

the runs each result of which is also kept as a dated report ({data}/project/reports/{run}/{date}.json): evidence

const REPORTED = ['restore-test', 'harden']

RUNS

run => what it is: label, changes (whether it changes something: a dry run by default, then confirmed; on sites, their names typed again unless confirm is false: what writes only here, or adds without replacing), targets (whether it acts on the sites of deploy.json: --targets=), remote (whether it reaches the servers)

const RUNS = […37 items]

SIDES

a data run's side that wins what both changed differently (admin.php's --prefer=)

const SIDES = ['local', 'target']

WHERE

where a backup run deletes: a site's server, this machine, both (admin.php's --where=)

const WHERE = ['server', 'local', 'server,local']

Properties1

project

protected MMO\admin\monitoring\LocalProject $project
Type
LocalProject

Methods43

audit($say, $result)

ProjectRuns.php:826

The project's third-party dependencies against the known vulnerabilities: composer audit when it has a composer.json, npm audit when it has a package.json (each when its tool is there).

protected function audit(callable $say, array &$result): array
$saycallable
$resultarray
returnsarraybool, audited: list<string>}

concurrency($names)

ProjectRuns.php:580

How many sites a batch runs at once by default: what each server can take -- its free processors, from its last reading (cpu.count, load.perCpu), two per site, one to four; one when it was never read -- up to the sites it hosts, added up, and no more than this machine's processors but one (each site is a php process here).

function concurrency(array $names): array
$namesarraythe sites
returnsarrayint, local: int, servers: array<string, array{sites: int, cpus: ?int, load: ?float, slots: int}>}

confirmation($typed)

ProjectRuns.php:198
protected function confirmation(string $typed): string
$typedstring
returnsstringnames typed as a, b or b,a: sorted, comma-separated

decrypt($file, $config, $say)

ProjectRuns.php:787
protected function decrypt(string $file, array $config, callable $say): string
$filestringan encrypted dump (.age)
$configarraythe hub's restoreTest: its identity
$saycallable
returnsstringthe dump decrypted into this machine's temporary folder, readable by its owner only

domains($say, $result)

ProjectRuns.php:850

When each domain of the sites expires: their registry's RDAP answer (rdap.org finds it), one question a domain.

protected function domains(callable $say, array &$result): array
$saycallable
$resultarray
returnsarraybool, domains: int}

drift($say, $result)

ProjectRuns.php:696

For each site asked (every one when none is), the keys of its live configs/prod.json against the same file at its ref: keys only, never their values -- they are its secrets. Read over ssh, read only.

protected function drift(callable $say, array &$result): array
$saycallable
$resultarray
returnsarraybool, sites: int} how many sites were read; each one's keys in $result['drift']

dumps($target)

ProjectRuns.php:935

A site's dumps, to restore one (restore's file): those of its server's backup folder, newest first, then those of this machine's backups (a backup fetched here), which admin.php uploads before restoring.

function dumps(MMO\admin\entities\Target $target): array
$targetTargeta site of deploy.json
returnsarraystring, where: string, size: int, at: int}> where is server or local
throwswhen the server cannot be reached

execute($run, $options, $say, $progress, $stop)

ProjectRuns.php:308

Run a run's steps one after the other, saying each line they print; stop at the first that fails, or when asked.

function execute( string $run, array $options, callable $say, ?callable $progress = null, ?callable $stop = null ): array
$runstring
$optionsarraywhat options returned
$saycallable
$progress = nullnull | callable
$stop = nullnull | callable
returnsarraymixed> run, label, options, ok, at, seconds, steps (list), and what a run adds: tests, i18n, a batch's targets, concurrency, dataStatus, stopped -- what last gives back

executeBatch($run, $options, $say, $progress, $stop)

ProjectRuns.php:371

A run of BATCHED: each site its own process, several at a time, the others going on when one fails.

protected function executeBatch( string $run, array $options, callable $say, ?callable $progress, ?callable $stop ): array- a release or a ship ([`PREBUILT`](https://mmoframework.fr/en/documentation/mmo.admin/php/monitoring/ProjectRuns.md#projectruns-prebuilt), applied) builds every site's artifact first, in one process: none built twice at once; - one that changes the sites, applied to several, runs the first alone (`canary`), the others once it passed; - at most `concurrency` sites at once (default: [`concurrency`](https://mmoframework.fr/en/documentation/mmo.admin/php/monitoring/ProjectRuns.md#projectruns-concurrency), and then at most each server's own slots). Each site's outcome is kept ([`saveTarget`](https://mmoframework.fr/en/documentation/mmo.admin/php/monitoring/ProjectRuns.md#projectruns-savetarget)) and said as it changes: the progress's fourth argument, site => its state (`waiting`, `running`, `done`, `failed`, `skipped`, `stopped`).
$runstring
$optionsarrayoptions
$saycallable
$progressnull | callable
$stopnull | callable
returnsarraymixed> execute's, and targets: site => {state, exitCode, seconds}; steps one per site (its last lines)

flushSite($site, $say)

ProjectRuns.php:516

Say what a site printed last, without its end of line.

protected function flushSite(array $site, callable $say): void
$sitearray
$saycallable
returnsvoid

getFolder()

ProjectRuns.php:877
function getFolder(): string
returnsstringthe folder keeping the runs' results: the hub's data, project/

i18n($say, $result)

ProjectRuns.php:675
protected function i18n(callable $say, array &$result): array
$saycallable
$resultarray
returnsarraybool, counts: array} the translation audit of the project, its libraries' dictionaries known

IsChatter($line)

staticProjectRuns.php:644
static function IsChatter(string $line): bool
$linestring
returnsboolwhether a line is the framework's own log below a warning (12.info MMO\core\PackageManager: include..., the ### header of a run): what the project's command line prints of itself, not what it did

keepBackups($name, $json, $code, $result, $say)

ProjectRuns.php:564

Keep what backups -m read of a site (BackupInventory): unknown with why when it was not read.

protected function keepBackups(string $name, array $json, int $code, array &$result, callable $say): bool
$namestring
$jsonarray
$codeint
$resultarray
$saycallable
returnsboolwhether it was read

keepDataStatus($name, $json, $code, $result, $say)

ProjectRuns.php:539

Keep what data-status -m read of a site (SyncStatus): unknown with why when it was not read.

protected function keepDataStatus(string $name, array $json, int $code, array &$result, callable $say): bool
$namestring
$jsonarray
$codeint
$resultarray
$saycallable
returnsboolwhether it was read

keepTypes($name, $json, $code, $result, $say)

ProjectRuns.php:551

Keep what section-types -m read of a site (TypeOverrideStatus): unknown with why when it was not read.

protected function keepTypes(string $name, array $json, int $code, array &$result, callable $say): bool
$namestring
$jsonarray
$codeint
$resultarray
$saycallable
returnsboolwhether it was read

Keys($data, $prefix)

staticProjectRuns.php:725
static function Keys(array $data, string $prefix = ''): array
$dataarray
$prefix = ''string
returnsarraythe paths of a configuration's keys, A/b/c, its comments left out: what drifts

lastSuccess($run)

ProjectRuns.php:919
function lastSuccess(string $run): ?array
$runstring
returnsnull | arraythe last result of a run that passed: its newest report that is ok, else its last result when ok

lint($say)

ProjectRuns.php:654
protected function lint(callable $say): array
$saycallable
returnsarraybool, files: int, errors: int} php -l on the project's php files not committed yet

options($run, $options)

ProjectRuns.php:127

The options of a run, checked: nothing but what this class knows reaches a command line.

function options(string $run, array $options): array
$runstringone of RUNS
$optionsarrayparts (backup, restore of a set: databases, files, config; all by default), set (restore: a backup set's time, or latest: each site's own; instead of file, one dump of one site), prefer (a data run: local or target wins what both sides changed differently; none: a site with such a change is left as it is and fails -- data-merge needs one), withFiles (a data run: the sites' sync.optional paths too), concurrency (a batch's sites at once, concurrency by default), canary (a batch that changes the sites tries the first one alone: true by default), targets (names of deploy.json, a list or a,b), dryRun (true by default for a run that changes something), confirm (the targets' names typed again: a,b), to (rollback's release), fetch (backup's), package (pull/push: the project, or one of its libraries), restoreLocally (backup's: the dump into this machine's database), file (restore's dump, on the target or in the local backups), exec (cmd's command, one line), part (version's: patch, minor, major), count (history's entries)
returnsarraylist<string>, dryRun: bool, confirmed: bool, to: ?string, fetch: bool, package: string, restoreLocally: bool, file: ?string, exec: ?string, part: string, count: int}
throwsfor an unknown run, target, release or package, or a run that changes something asked without its confirmation

packageFolder($package)

ProjectRuns.php:256
protected function packageFolder(string $package): string
$packagestring
returnsstringthe folder of the project, or of one of its libraries

php()

ProjectRuns.php:261
protected function php(): string
returnsstringthe php command line binary: this one on the command line, the cli one beside it under a web server

phpstanSteps()

ProjectRuns.php:284
protected function phpstanSteps(): array
returnsarrayphpstan, when the project has its configuration and the phar is there (its own, or its libraries' clone's)

phpunit()

ProjectRuns.php:275
protected function phpunit(): string
returnsstringthe project's phpunit: its vendor's, its libraries' clone's, else the one on the PATH

process($command, $cwd, $say, $stop, $capture)

ProjectRuns.php:611
protected function process( string $command, string $cwd, callable $say, ?callable $stop, ?callable $capture = null ): int
$commandstring
$cwdstring
$saycallable
$stopnull | callable
$capture = nullnull | callable
returnsinta command's exit code, each line it printed said as it comes

restoreChecks($commands, $values, $say)

ProjectRuns.php:810

The project's checks of a restored dump: each a command line of the hub's restoreTest.checks, its placeholders replaced (each value quoted), run in the project's folder.

function restoreChecks(array $commands, array $values, callable $say): array
$commandsarray
$valuesarray
$saycallable
returnsarraystring, exitCode: int, ok: bool}>

restoreTest($say, $result)

ProjectRuns.php:747

Whether a backup restores (ISO 27001 A.8.13): the newest dump of the site asked (or of any site) among the project's local dumps (what backup --fetch brings: .mongo, or .mongo.age encrypted on its server), decrypted here with the hub's restoreTest.identity (the age private key of this machine, else MMO_BACKUP_IDENTITY) into a temporary file, restored into a scratch database of this machine's MongoDB, its collections counted, then restoreTest.checks run on it (the project's own, {database} the scratch database: my.oviepro's php admin.php data-guard ...), then dropped (restoreTest.prefix and the dump's database name: mmo_restoretest_{database}). Nothing of the project's own database is touched. Each test is kept as a dated report (reports), and the last one that passed is what the pages and the readiness show (lastSuccess).

protected function restoreTest(callable $say, array &$result): array
$saycallable
$resultarray
returnsarraybool, file: string, collections: int, documents: int}

runSites($run, $options, $names, $total, $servers, $result, $states, $say, $report, $stop)

ProjectRuns.php:435

Run some sites of a batch, each its own process: at most $total at once, and at most a server's slots on it.

protected function runSites( string $run, array $options, array $names, int $total, array $servers, array &$result, array &$states, callable $say, callable $report, ?callable $stop ): void
$runstring
$optionsarray
$namesarraythe sites, in order
$totalint
$serversarray
$resultarraythe batch's, given each site's step and outcome
$statesarray
$saycallable
$reportcallable
$stopnull | callable
returnsvoid

saveTarget($target, $run, $record)

ProjectRuns.php:897

Keep one site's outcome of a batch: the last of each run, per site, which another batch of other sites leaves as it is.

function saveTarget(string $target, string $run, array $record): void
$targetstring
$runstring
$recordarray
returnsvoid

sets($target)

ProjectRuns.php:956

A site's backup sets (BackupSets): from its server's backups and this machine's, newest first.

function sets(MMO\admin\entities\Target $target): array
$targetTarget
returnsarraystring, at: int, parts: array}>
throwswhen the server cannot be reached

siteLine($site, $name, $type, $line, $say)

ProjectRuns.php:523

One line a site printed: its json kept (data-status, section-types), the framework's chatter left out, the rest said and kept.

protected function siteLine(array $site, string $name, int $type, string $line, callable $say): void
$sitearray
$namestring
$typeint
$linestring
$saycallable
returnsvoid

startSite($run, $options, $name, $server, $say, $before, $code)

ProjectRuns.php:495
protected function startSite( string $run, array $options, string $name, string $server, callable $say, ?array $before = null, ?int $code = null ): array
$runstring
$optionsarray
$namestring
$serverstring
$saycallable
$before = nullnull | arraythe site's step before (steps' after): its lines, its json and its code carried on
$code = nullnull | intwhat the site ends with, whatever this step ends with (a step after)
returnsarraystring, process: Process, command: string, server: string, began: float, lines: \ArrayObject<int, string>, json: \ArrayObject<string, mixed>, buffers: \ArrayObject<int, string>, after: list<array>, code: ?int} one site's process, started

steps($run, $options)

ProjectRuns.php:210

The steps of a run: each a command line, run in a folder; or call, run in this process.

function steps(string $run, array $options): array
$runstring
$optionsarraywhat options returned
returnsarraystring>> label, and command and cwd, or call; junit where a test step writes its results

testsStep()

ProjectRuns.php:266
protected function testsStep(): array
returnsarraystring, command: string, cwd: string, junit: string} the project's phpunit, its results as junit