Skip to main content
InterviewHubPRO
Section Overview
Q1

Question 1 of 50

Part 1: Core Language, Execution Lifecycle & Types (1 - 10)

2%
PHP & Zend Engine (50 Qs)•Part 1: Core Language, Execution Lifecycle & Types (1 - 10)

How does the PHP Execution Lifecycle work (SAPI, FastCGI, and PHP-FPM)?

senior LevelLifecycleHTTP & REST APIs

In Simple Words: PHP does not run as a continuous in-memory application server by default. Instead, it follows a Share-Nothing Architecture where each incoming HTTP request executes in an isolated process/thread, initializes state, runs code, and completely destroys all memory on request termination.

Lifecycle Stages:

  1. Module Init (MINIT): Triggered once when PHP-FPM starts. Loads extensions and registers persistent constants.
  2. Request Init (RINIT): Triggered for every incoming HTTP request. Allocates request memory pool and initializes $_GET, $_POST, and $_SERVER.
  3. Execution: The Zend VM executes compiled opcodes.
  4. Request Shutdown (RSHUTDOWN): Cleans up user-defined objects, runs output buffering flushes, and frees request memory.
  5. Module Shutdown (MSHUTDOWN): Triggered when PHP-FPM stops.