Migrating From FPM or Octane
Moving to PAM changes how your application is served, not how it is written. This guide lists what changes, side by side, and the gotchas worth checking before you switch production traffic.
From PHP-FPM and Nginx
Section titled “From PHP-FPM and Nginx”What Changes
Section titled “What Changes”| Concern | PHP-FPM + Nginx | PAM |
|---|---|---|
| Entry point | public/index.php per request |
pam.php, booted once per worker |
| Processes | Nginx + FPM master + FPM children | PAM master + workers |
| Concurrency | pm.max_children |
pam start --workers N |
| Recycling | pm.max_requests |
--max-requests N |
| Static files | Nginx try_files |
A reverse proxy or CDN (recommended), or Laravel |
| Health | Custom | /live, /ready, /metrics on --admin-address |
| Reload | systemctl reload php-fpm |
kill -HUP <master> (new generation, then drain) |
| Artisan | php artisan |
pam artisan |
| Composer | composer |
pam composer |
-
Add
pam.phpto the project root (Installation). -
Run your test suite under PAM:
Terminal window pam artisan test -
Audit persistent state: search for
staticproperties that hold per-request data, singletons built from the request or user, andsetlocale()/ini_set()calls. See Request Lifecycle. -
Install the production tooling and turn on strict leak detection in staging:
Terminal window pam composer require pushinbr/pam-laravelpam artisan pam:install --preset=api.env (staging) PAM_LARAVEL_STATE_GUARD_STRICT=true -
Run the persistent smoke test with your real routes.
-
Put PAM behind your existing Nginx (keep it for TLS and static files):
/etc/nginx/sites-available/example.com server {listen 443 ssl http2;server_name example.com;root /srv/app/current/public;location / {try_files $uri @pam;}location @pam {proxy_pass http://127.0.0.1:3000;proxy_http_version 1.1;proxy_set_header Host $host;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;}}and trust the proxy in Laravel (
bootstrap/app.php,$middleware->trustProxies(at: '127.0.0.1')) and inpam.php('trustedProxies' => ['127.0.0.1']). -
Replace the FPM service with a PAM service (Deploying Laravel).
Gotchas
Section titled “Gotchas”-
php.inisettings. PAM embeds its own PHP, so settings you tuned in FPM’sphp.ini(memory_limit,upload_max_filesize,post_max_size) must be passed to PAM, before the command name, with-dor-c:Terminal window pam -d memory_limit=512M -d upload_max_filesize=64M start pam.php --workers 8pam -c /etc/pam/php.ini start pam.php --workers 8 -
Request size.
maxBodyBytes(2 MiB by default) limits non-multipart bodies such as large JSON payloads. Raise it inpam.phpif needed. -
Timeouts. FPM’s
request_terminate_timeoutbecomesrequestTimeoutMs(30 s by default). -
exit()anddie()in application code do not just end the request: the client receives a500and PAM recycles the worker. Return a response or throw an exception instead (abort(403)). -
Deploys.
pam startruns OPcache withvalidate_timestamps=0. Code changes take effect after a reload, never mid-generation.
From Laravel Octane
Section titled “From Laravel Octane”You have two options.
Keep your Octane code and use PAM as the server:
pam composer require pushinbr/pam-octanepam artisan octane:install --server=pampam octane:startOctane’s lifecycle events, listeners, Octane::concurrently(), tables, and
ticks keep working. See Laravel Octane on PAM.
Run the audit:
pam artisan pam:migrate-from-octane+--------+--------------------+-------------------------------------------------------------------------+| Status | Item | Recommendation |+--------+--------------------+-------------------------------------------------------------------------+| review | dependency | Remove laravel/octane after PAM validation. || review | config/octane.php | Review Octane-specific lifecycle hooks and move cleanup to LifecycleHook. || action | server | Replace `octane:start` with `pam start pam.php --workers N`; keep ... || action | verification | Run pam:check-production, pam:leaks and production-like load tests. |+--------+--------------------+-------------------------------------------------------------------------+Then move cleanup you registered on Octane events (RequestTerminated,
OperationTerminated, listeners in config/octane.php) into a
LifecycleHook, and replace
octane:start with pam start pam.php --workers N.
Octane Concepts on PAM
Section titled “Octane Concepts on PAM”| Octane | Without Octane on PAM |
|---|---|
octane:start --workers=N |
pam start pam.php --workers N |
--max-requests |
--max-requests |
octane:reload |
kill -HUP <master> |
Octane::concurrently() |
Requires the Octane bridge with --task-workers |
Octane tables and octane cache |
Requires the Octane bridge |
RequestReceived / RequestTerminated listeners |
LifecycleHook from pushinbr/pam-laravel |
Octane’s flush list in config/octane.php |
scoped() bindings, or a LifecycleHook |
The rules for safe code are the same in both worlds: Octane and PAM both keep the application in memory, so code that is already Octane-safe is PAM-safe.