PHP Runtime in WordPress

Find out why the same plugin works on one host and white-screens on another: the path from request to wp-load.php.

3 lessons9 interview questions3 terminal practices

"It works on my machine" is not a PHP version. The same plugin runs locally and white-screens on the client's host. Different PHP, a different memory_limit, a stale OPcache. In this module you learn the path every request takes and where to look first when it breaks.

CoursePHP for WordPress Developers ยท Module 1 of 9 ยท Stage 1 "Language"
LearnHow WordPress runs PHP, why hosts differ and how to debug with WP_DEBUG, logs and Xdebug
HowShort lessons with code from real plugins, Terminal practice in the browser, interview questions after every lesson

The idea in one picture

flowchart LR
  R["HTTP request"] --> W["Web server<br/>nginx ยท Apache"]
  W --> F["PHP-FPM<br/>php.ini limits"]
  F --> O["OPcache<br/>compiled code"]
  O --> L["wp-load.php<br/>WordPress"]
  classDef step fill:#f5f3ff,stroke:#777BB4,color:#1e1b4b
  classDef key fill:#777BB4,stroke:#4f5b93,color:#ffffff

One request, four stops. Each one has its own settings, and each one can be the reason a plugin breaks on a client's host.

Before โ†’ after

BeforeAfter Module 1
"It works locally" โ€” and nothing moreYou compare PHP version, limits and OPcache first
A white screen and no idea whyWP_DEBUG_LOG and error_log show the cause
var_dump() on productionXdebug and logs locally
No Requires PHP in the pluginThe header protects old sites from a fatal error

You'll be able to answer

  • What is PHP-FPM and how does it differ from mod_php?
  • What does OPcache do and when do you need to reset it?
  • Why should a plugin declare Requires PHP?

Lessons in this module 3 lessons