Home >Backend Development >PHP Problem >How to understand PHP architecture layout

How to understand PHP architecture layout

醉折花枝作酒筹
醉折花枝作酒筹forward
2021-05-11 17:19:421879browse

This article will introduce you to the PHP architecture layout. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

How to understand PHP architecture layout

Execution process

It can be seen from the above figure that there are mainly four stages from parsing PHPCode to execution.

How to understand PHP architecture layout

To obtain token, you can obtain token information through the Token_get_all('<?php echo "str";>') function.

Abstract syntax tree mainly decouples the interpreter and compiler.

The instructions that opcodes are ultimately executed, such as ZEND_ECHO: are essentially a corresponding C function.

Architecture structure

How to understand PHP architecture layout
The Zend layer provides some basic memory management and data structures for the upper PHP layer.

The SAPI layer communicates with the server for the upper layer, encapsulating different communication types. cgi, fast-cgi, cli, etc.

Directory structure

sapi

stores the upper-layer API interaction forms supported by different environments, and implements different input and output forms.

Zend

Stores PHP-related core code, memory management, etc. as mentioned above.

main

is responsible for the entrance to interact with the Zend layer, and Some hook functions.

ext

Mainly expand related directories. Generate custom modules through the ext_skel command. They will be installed in this directory by default.

TSRM

Directories related to thread resource management, generally only when used in conjunction with Apache, will involve code related to thread resource management.
Those related to Nginx will generally only use the FastCGI protocol and not involve it. TSRM module.

Recommended learning: php video tutorial

The above is the detailed content of How to understand PHP architecture layout. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete