Skip to content

PHP API, Hooks & CLI

ProcessReactExportProfile exposes its domain coordinator via $modules->get('ProcessReactExportProfile')->runtime() (Totoglu\ProcessReactExportProfile\ExportProfileRuntime), one extension hook (ProcessReactExportProfile::collectContributors), one background queue (ExportProfileQueue), and 4 CLI commands.

Method Description
ExportProfileRuntime::make(ProcessWire $wire) Instantiates and wires a runtime coordinator.
collector(), repository(), presetStore(), auditor(), verifier(), runner() Accessors for the underlying domain services.
collectRulesWithModuleHook() Collects and merges all contributor rules including ProcessReactExportProfile::collectContributors.
runAudit(?ExportPlan $plan = null) / getCachedAudit(bool $forceRefresh = false) Runs or reads the 60-second cached pre-flight site audit.
invalidateAuditCache() Clears the cached audit snapshot in WireCache.
buildDefaultPlan(array $auditReport, MergedContributorRules $rules) Builds a safe default ExportPlan from live site discovery.
validatePlan(ExportPlan $plan) Validates an ExportPlan and returns localized error messages.
dispatchQueueExport(ExportPlan $plan, bool $allowCustomFinishPhp = false) Dispatches an asynchronous ExportProfileQueue job.
verifyProfile(string $slug, bool $persistMetadata = false) Runs ProfileVerifier on an exported profile and optionally updates saved metadata.
redactPathsForNonSuperuser(array $payload, bool $isSuperuser) Strips host root paths for non-superuser responses.
audit(string $action, string $outcome, array $context = []) Writes a structured record to react-export-profile-audit.
Hook Arguments & Return Timing What It Does
ProcessReactExportProfile::collectContributors (ContributorCollector $collector): void After Fires during audit and export planning so modules can register custom ProfileContributorInterface rules (extra excluded tables, secret key patterns, or post-install hooks).
ProcessReactExportProfile::translations (): array After Returns the localized UI string dictionary for the Setup -> Export Site Profile React workspace.

Register a Custom Export Contributor & Override Workspace Labels

Section titled “Register a Custom Export Contributor & Override Workspace Labels”
site/ready.php
<?php
declare(strict_types=1);
namespace ProcessWire;
use Totoglu\ProcessReactExportProfile\Contributor\ContributorCollector;
$wire->addHookAfter('ProcessReactExportProfile::collectContributors', function (HookEvent $event): void {
/** @var ContributorCollector $collector */
$collector = $event->arguments(0);
$collector->register(new AegeanVoyagesProfileContributor());
});
$wire->addHookAfter('ProcessReactExportProfile::translations', function (HookEvent $event): void {
$strings = (array) $event->return;
$strings['workspace.title'] = 'Aegean Profile Exporter';
$event->return = $strings;
});

All 4 CLI Commands & Flags (vendor/bin/wire)

Section titled “All 4 CLI Commands & Flags (vendor/bin/wire)”

Runs a full pre-flight audit reporting tables, detected secrets, dev junk, and contributor rules:

Terminal window
php vendor/bin/wire profile:audit --json

Flags: --json.

Exports a site profile using a built-in or saved preset, either synchronously or via ExportProfileQueue:

Terminal window
php vendor/bin/wire profile:export \
--preset=client-handoff \
--target=aegean-voyages-handoff \
--mode=zip \
--title="Aegean Voyages Starter" \
--summary="Sanitized Aegean yacht charter starter" \
--queue \
--dry-run \
--force \
--json
Flag Description
--preset Built-in (public-starter, client-handoff, internal-clone) or custom site/profiles/*.json preset slug.
--target Output profile slug (site-{target}).
--mode Output mode (both, directory, or zip).
--title Profile display title written to install/info.php.
--summary Profile summary written to install/info.php.
--queue Dispatch the export asynchronously via ExportProfileQueue.
--include-users Include user accounts (superuser-only; omitted by default).
--no-scrub-secrets Disable automatic secret scrubbing (superuser-only; never use for public profiles).
--dry-run Validate and preview the export plan without writing files.
--force Overwrite existing profile or skip interactive confirmation in CI.
--json Emit structured JSON result.

Lists all exported profiles, sizes, verification statuses, and available presets:

Terminal window
php vendor/bin/wire profile:list --json

Flags: --json.

Runs ProfileVerifier on an exported profile directory and/or ZIP archive to verify installer files and zero leaked secrets:

Terminal window
php vendor/bin/wire profile:verify aegean-voyages-handoff --json

Flags: --json.

Symptom: ZIP archive creation fails in FileArchiver::archiveDirectoryToZip().

Fix: Install and enable PHP’s ext-zip extension, or export with --mode=directory if you only need a server directory copy.

Symptom: profile:verify reports a secret literal match inside a template or custom module file.

Fix: Move hardcoded keys out of site/templates/ into environment variables or site/config.php (which ConfigCompiler scrubs automatically), or register the custom key name via ProfileContributorInterface and re-export.

  • Running ExportProfileQueue: When exporting with --queue or via the Workbench background mode, ensure a trk/processwire-console worker is active:

    Terminal window
    php vendor/bin/wire queue:work --tries=3 --sleep=3
  • Demo Mode ($config->demo = true): Blocks destructive profile deletions, raw archive exports containing sensitive settings, and custom finish.php hooks.

  • 6-Locale Translation Packs: Bundled CSV packs (en, tr, de, fr, es, ru) live in site/modules/ProcessReactExportProfile/languages/. Import the matching .csv file under Setup -> Languages -> [Language] -> Site Translation Files.

Next steps