Production performance

Pionia ships readable PHP source. Performance is opt-in at deploy time — nothing is preloaded or cached until you run php pionia optimize.

composer install --no-dev -o
php pionia optimize --production

--production enables:

  • Authoritative Composer classmap (composer dump-autoload -o -a)
  • Bootstrap cachesstorage/bootstrap/routes.php and providers.php
  • Hybrid preload — stats snapshot hits + minimum app paths + shipped framework manifest

Restart PHP-FPM or RoadRunner workers after deploy when opcache.validate_timestamps=0.

Two timelines

WhenWhat happens
bin/release (framework maintainers)Generates portable framework-preload.php into the Packagist zip, then removes it from the git tree
php pionia optimize (your app)Installs opt-in scaffold files and generates app-specific storage/bootstrap/preload.php

Consumer apps never commit framework preload manifests — they ship inside vendor/pionia/pionia-core after composer install.

Commands

CommandPurpose
php pionia optimizeFull deploy optimization (scaffold + autoload + preload + bootstrap caches)
php pionia optimize --productionRecommended production preset
php pionia optimize:preloadRegenerate preload only
php pionia optimize:preload --snapshotRecord OPcache snapshot, then regenerate
php pionia optimize:preload --from-statsUse existing storage/metrics/opcache-snapshot.json
php pionia optimize:preload --strategy=curated|stats|hybridOverride PRELOAD_STRATEGY
php pionia optimize:clearRemove generated artifacts
php pionia optimize:clear --scaffoldAlso remove opt-in scaffold files

Options on optimize: --no-scaffold, --no-preload, --no-autoload, --authoritative, --bootstrap-cache.

First-time scaffold (opt-in)

The default pionia new template does not include preload wiring. The first php pionia optimize installs:

FileRole
bootstrap/preload.phpStable entry — point php.ini opcache.preload here
environment/php.ini.production.exampleProduction OPcache / JIT directives
[performance] in settings.iniPreload and bootstrap cache toggles

Generated artifacts (gitignored):

FileRole
storage/bootstrap/preload.phpApp opcache_compile_file() list
storage/bootstrap/routes.phpCached route table
storage/bootstrap/providers.phpCached provider map
storage/metrics/opcache-snapshot.jsonHot-script snapshot from workers
vendor/.../framework-preload.phpFramework manifest (from Packagist)

OPcache preload

bootstrap/preload.php requires the generated storage/bootstrap/preload.php, which in turn:

  1. requires the shipped framework manifest (framework-preload.php in pionia-core)
  2. Calls opcache_compile_file() for app services, switches, and selected vendor packages

Copy environment/php.ini.production.example into your PHP pool config:

opcache.enable=1
opcache.enable_cli=1
opcache.preload=/app/bootstrap/preload.php
opcache.preload_user=www-data
opcache.validate_timestamps=0
opcache.jit=1255

opcache.enable_cli=1 is required for RoadRunner workers.

RoadRunner without global php.ini

server:
  command: "php -d opcache.enable_cli=1 -d opcache.preload=./bootstrap/preload.php worker.php"

settings.ini

[performance]
PRELOAD_ENABLED=true
PRELOAD_STRATEGY=hybrid
PRELOAD_AUTHORITATIVE=true
BOOTSTRAP_CACHE=true
RECORD_OPCACHE_SNAPSHOT=true
PRELOAD_PATHS=
PRELOAD_EXCLUDE=
KeyValuesPurpose
PRELOAD_STRATEGYcurated, stats, hybridHow to build the preload file list
PRELOAD_AUTHORITATIVEtrue / falsePass -a to composer dump-autoload
BOOTSTRAP_CACHEtrue / falseLoad cached routes/providers at boot
RECORD_OPCACHE_SNAPSHOTtrue / falseWorkers write hot-script snapshot

Preload strategies

StrategyBehaviour
curatedScan framework core (or use shipped manifest), app dirs, and key vendor packages
statsUse OPcache live status or recorded snapshot only
hybridMerge snapshot hits with minimum app paths (default)

Stats-driven preload workflow

  1. Staging — run with RECORD_OPCACHE_SNAPSHOT=true. Workers throttle-writes storage/metrics/opcache-snapshot.json after requests.
  2. Pre-cutoverphp pionia optimize:preload --snapshot or php pionia optimize --production.
  3. Deploy — restart workers; verify /stats OPcache section.

Monitoring

/stats reports OPcache hit rate, preload memory, JIT status, and cached script counts. See Developer stats.

What not to preload

Avoid preloading the entire vendor/ tree — shared memory grows quickly with little benefit on small APIs. The generator uses a curated manifest plus optional real-traffic stats.