PHP 8: Modern PHP Development · Performance and Deployment
OPcache, Preloading and the JIT
Configure OPcache for production and understand when the JIT helps.
OPcache caches compiled bytecode in shared memory so PHP doesn't re-parse files on every request — the single biggest PHP performance setting. In production set opcache.validate_timestamps=0 (reset on deploy), give it enough memory and file slots, and consider preloading (opcache.preload) for frameworks. The JIT (8.0+) compiles hot code to machine code; it helps CPU-heavy workloads (math, image processing) but rarely speeds up typical I/O-bound web apps.
; php.ini (production)
opcache.enable=1
opcache.memory_consumption=256
opcache.interned_strings_buffer=32
opcache.max_accelerated_files=50000
opcache.validate_timestamps=0 ; restart/reload FPM on deploy
opcache.jit=tracing ; optional; measure first
opcache.jit_buffer_size=64M
Common pitfalls
validate_timestamps=0without reloading FPM on deploy — old code keeps running.- Too few
max_accelerated_files, causing cache misses on large codebases. - Expecting the JIT to fix slow database queries.
Key points
- OPcache is essential in production
- Reload FPM on deploy when timestamps aren't validated
- JIT helps CPU-bound code, not I/O
Further reading: PHP manual: OPcache configuration
Practice questions
Why set opcache.validate_timestamps=0 in production?
Answer
PHP stops checking file modification times on every request, saving syscalls. Code is immutable between deploys, and the deploy process reloads PHP-FPM to clear the cache.
Will enabling the JIT speed up a typical Laravel app?
Answer
Usually only slightly. Most time is spent on I/O (database, network) and framework overhead; the JIT benefits CPU-intensive code.
Open in the app to mark lessons complete, take notes and track your progress.