API / Minn\Cli / Installer

Installer final class

Minn\Cli\Installer · public/minn/src/Minn/Cli/Installer.php · 324 lines

The swap, both ways. Install parks WordPress's own files beside the webroot, lays the engine and its shape files down, and leaves wp-config.php and wp-content untouched; eject puts every parked file back and removes what install wrote. The install record at the webroot (.minn-install.php) is what eject works from. Preflight says what the site will and will not get before anything moves.

Constants and properties

privateRECORD = '.minn-install.php'

The install record sits at the webroot, so every site keeps its own (a symlinked minn/ is shared between sites) and an engine update cannot take it. It is PHP that returns first, so a web request for it prints nothing, and it names the webroot it belongs to.

privateRECORD_HEAD = '<?php return; // Minn Engine\'s install record: what `wp minn eject` puts back. ?> '
privateLEGACY_RECORD = '.install.json'

Where installs kept it before: read from a site's own minn/ copy, never through a shared symlink.

privateCORE_ENTRIES = array ( 0 => 'wp-admin', 1 => 'wp-includes', 2 => 'index.php', 3 => 'wp-activate.php', 4 => 'wp-blog-header.php', 5 => 'wp-comments-post.php', 6 => 'wp-config-sample.php', 7 => 'wp-cron.php', 8 => 'wp-links-opml.php', 9 => 'wp-load.php', 10 => 'wp-login.php', 11 => 'wp-mail.php', 12 => 'wp-settings.php', 13 => 'wp-signup.php', 14 => 'wp-trackback.php', 15 => 'xmlrpc.php', 16 => 'license.txt', 17 => 'readme.html', )

The files WordPress keeps at the webroot, moved aside as a set.

privateWRITTEN_TREES = array ( 0 => 'wp-includes', 1 => 'wp-admin', )

Webroot trees install writes (shape files + require placeholders) and eject deletes before restoring the park.

privateLEGACY_PUBLISHED = array ( 0 => 'minn-admin-asset', 1 => 'minn-engine', 2 => 'wp-includes/js/jquery', )

Leftover webroot copies from an earlier installer that published assets outside minn/. Eject still deletes them.

privateSKIP = array ( 0 => '.git', 1 => 'node_modules', 2 => 'tests', 3 => 'docs', 4 => '.DS_Store', 5 => '.install.json', )

Development-only trees inside the engine or the admin bundle that never ship.

privatearray $lines
privatereadonly string $engineDir

Promoted from the constructor.

Public

new__construct(string $engineDir)#
staticmain(array $argv, string $engineDir): int#

The bin entry: runs one command against a webroot and returns the exit code.

$argvlist<string>
methodpreflight(string $root): string#

What the site will and will not get; the worst light decides install. The report lands in the output.

methodupdate(array $options): int#

Replaces this engine with the latest release from the Minn update service; --check only says whether there is one.

methodstatus(string $root): int#

Prints what the webroot is running.

methodinstall(string $root, array $options): int#

Installs the engine into a webroot when the preflight allows it.

$optionsarray<string, string|true>
methodeject(string $root): int#

Puts WordPress back and removes the engine's files.

staticstate(string $root): string#

What a webroot is running: minn, wordpress, or unknown.

staticrecord(string $root): array#

The install record for a webroot: its owner, when, the engine version, the park, what moved, what was laid down. Empty when there is none, or when the one found names another webroot (a site that was moved or copied keeps a record its own eject must not act on).

@return array<string, mixed>

Internals 6

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatehelp(): int#
privateinside(string $path): bool#

Whether a path from the install record stays inside the webroot (or the park): relative, with no climbing segment and no NUL. The record is a file in the webroot, so anything able to write there could otherwise point an eject's removals anywhere the operator can write.

privatemove(string $from, string $to): void#

rename() first; copy+remove when the park is on another filesystem.

privatecopyTree(string $from, string $to): void#
privateversion(): string#
privatesay(string $line): void#