Explain the PHP request lifecycle from the moment a request hits the server to the moment it is terminated.

Last updated 15 June 2026

  • Once per process, MINIT (module init) registers extensions, constants and classes. MSHUTDOWN releases them when the process ends.

  • Per request, RINIT populates superglobals. The Zend Engine compiles the script to opcodes (cached by OPcache) and executes them. RSHUTDOWN then runs shutdown functions, flushes output, writes sessions and frees memory.

  • Under FPM the process persists, so module phases run rarely while request phases run on every request.

  • https://www.phpinternalsbook.com/php7/extensions_design/php_lifecycle.html
  • https://levelup.gitconnected.com/writing-a-tiny-php-extension-what-php-src-looks-like-from-the-outside-b878b31eec68
  • https://www.survivethedeepend.com/articles/request-lifecycle-explained-for-php-developers/
  • https://medium.com/gitconnected/writing-a-tiny-php-extension-what-php-src-looks-like-from-the-outside-b878b31eec68
  • https://engineers.fenrir-inc.com/entry/2022/12/26/113630
  • https://wiki.php.net/internals/extensions
  • https://medium.com/tech-vibes/tracing-request-lifecycles-in-php-without-external-apms-4ff4c4b7b47b
All PHP interview questions