How php/php-src works
PHP is a general-purpose scripting-language interpreter with bundled extensions. Its principal workflow is a script entering through a SAPI, being compiled into engine instructions, and executed to produce program behavior. The graph also shows the optimizer, object handling, shared runtime facilities, and representative extensions. Relationships are conservative: unsampled runtime call paths are dashed and unverified; solid edges are supported by the README or SOURCE INDEX references.
Main entry points: main.c PHP runtime · zend_API.h Engine API · zend_object_handlers.c Object handlers · SAPI.h SAPI interface
Components 21
Runtime entry
- SAPI interface
main/SAPI.h - PHP runtime
main/main.c
Zend engine
- Compiler
Zend/zend_compile.c - Optimizer
Zend/Optimizer/zend_optimizer.c - Instruction executor
Zend/zend_execute.c - VM handlers
Zend/zend_vm_execute.h - Object handlers
Zend/zend_object_handlers.c - Engine API
Zend/zend_API.h
Runtime services
- Engine types
Zend/zend_types.h - Memory allocation
Zend/zend_alloc.h - Hash tables
Zend/zend_hash.h - Variables
Zend/zend_variables.h - Operators
Zend/zend_operators.h - Exceptions
Zend/zend_exceptions.h - PHP streams
main/php_streams.h
Bundled extensions
- Random APIs
ext/random/php_random.h - Random algorithms
ext/random/engine_mt19937.c - Date and time
ext/date/php_date.c - DOM and XML
ext/dom/php_dom.c - cURL extension
ext/curl/interface.c
Other components
- PHP script
Connections 15
- PHP script → SAPI interface: enters through
- SAPI interface → PHP runtime: dispatches to
main/main.c - PHP runtime → Compiler: invokes
- Compiler → Optimizer: optimizes
- PHP runtime → Instruction executor: invokes
- Instruction executor → VM handlers: dispatches to
- PHP runtime → Engine API: includes API
main/main.c - PHP runtime → PHP streams: includes streams
main/main.c - Engine API → Variables: references
Zend/zend_API.h - Engine API → Operators: references
Zend/zend_API.h - Object handlers → Engine API: uses API
Zend/zend_object_handlers.c - Object handlers → Exceptions: uses exceptions
Zend/zend_object_handlers.c - PHP runtime → Memory allocation: uses allocation
- PHP runtime → Hash tables: uses tables
- Random APIs → Random algorithms: exposes algorithms
ext/random/engine_mt19937.c