SlideShare a Scribd company logo
The PHP Lifecycle
Yahoo! . 惠新宸
       Tel : 86111
       Mail: laruence@yahoo.com.cn
Summary

•   B/S(HTTP Request Cycle)
•   Apache Life Cycle
•   Apache Parse Request Cycle
•   PHP Life Cycle
•   Cooperating with Apache
•   PHP Parse/Execute Process
•   Now We Can…


         Linux/Unix + Apache 1.3x + PHP 5.x
B/S




1. Client Request
2. Server Parse Requst and Send Response
3. Client interpret Responded Text/HTML/Json etc…
Apache Life Cycle
Apache Parse Request Cycle
PHP Life Cycle

•   In command line mode(CLI)
PHP Life Cycle con’t

•   PHP_MODULE_ENTRY(php_mysql.c 215 行 )
PHP Life Cycle con’t

•   PHP_MINIT_FUNCTION(php_mysql.c 378 行 )
PHP Life Cycle con’t

•   PHP_RINIT_FUNCTION(php_mysql.c 473 行 )
PHP Life Cycle con’t

•   PHP_SHUTDOWNS(php_mysql.c 403 行 )
PHP Life Cycle con’t

•   In DSO mode
     – Single process
PHP Life Cycle con’t

•   In DSO mode
     – Multiprocess
PHP Life Cycle con’t

•   In CGI mode
     – Multithreaded
Cooperation

•   Apache 1.3x + PHP 5.x in DSO mode
•   Dynamic Shared Objects (DSO)
    – mod_dso
        • src/modules/standard/mod_so.c 347 行
Cooperation con’t

•   Php Module 注册 Handler
    – mod_php5.c 963 行
Cooperation con’t

•   Php Module 注册 Handler
    – mod_php5.c 987 行
Cooperation con’t

•   http.conf
PHP Parse/Execute Process
PHP Parse/Execute Process con’t

•   Scan(lex)
     –   Zend/zend_language_scanner.c 3047 行

    ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type TSRMLS_DC){
             retval = op_array;
             ….
             return retval;}

     –   Zend/zend_language_scanner.l
                                                       T_OPEN_TAG: '<?php '
                                                       =
          <?php                                        T_LNUMBER: '1'
            $sum = 1 + 2;                              +
            echo “1+2=“.$sum;                          T_LNUMBER: '2'
          ?>                                           T_ECHO: 'echo''
                                                       T_CONSTANT_ENCAPSED_STRI
                                                       NG: ''1+2=''.
                                                       T_CLOSE_TAG: '?>'
PHP Parse/Execute Process con’t

•   Parse/Complie(yacc)
     – zend_language_parser.y

     T_OPEN_TAG: '<?php '
     =                          Opcode     Op1     Op2        Result
     T_LNUMBER: '1'             ADD         1       2          $tmp0
     +                          ASSIGN   $cv0(sum) $tmp0      $var1
     T_LNUMBER: '2'             CONCAT    '1+2='  $cv0(sum)   $tmp2
     T_ECHO: 'echo''            ECHO      $tmp2
     T_CONSTANT_ENCAPSED_STRI   RETURN      1
     NG: ''1+2=''.
     T_CLOSE_TAG: '?>'
PHP Parse/Execute Process con’t

•   Execute
    – Zend/zend_execute.c

     void (*zend_execute) (zend_op_array *op_array TSRMLS_DC);



•   Zend_op_array
    – Zend/zend_compile.h
                                 struct zend_op{
                                  opcode_handler_t handler;
                                  znoderesult;
                                  znodeop1;
                                  znodeop2;
                                  ulongextended_value;
                                  uintlineno;
                                  zend_ucharopcode;
                                 };
PHP Parse/Execute Process con’t

•   Execute
    – Zend/zend_opcode.c 428 行
A sample

•   Clien Request
A sample

•    http_main.c 8053
      –    main() call ap_main

•         ap_main => REALMAIN
      –    REALMAIN(argc, argv)
      –    http_main.c

•    child_main
      –    Call child_sub_main 6134

•    chile_sub_main
      –    loop worker
      –    call ap_process_request(r) on request

•    http_reqeust.c 1308
•    ap_process_request
      –    call process_request_internal

•    process_request_internal
      –    call ap_invoke_handler

Application/x-httpd-php -> send_parsed_php
A sample

•   Server Pares
     – URI
        • Filename -> /test/index.php
    – User Auth
    – …
    – MIME type Check
        • application/x-httpd-http
    – Call handler
        • send_parsed_php(request_rec *)
        • Zend_execute_script(…..request_rec->filename);
A sample

• Zend/zend.c 1073 行
A sample


•   Index.php

        <?php
           echo 2+3;
        ?>
A sample

•   Zend_language_scanner.l 362 行




•   Zend_language_parse.c 62 行
A sample

•    Parser
      –   Zend_language_parse.y




      –   Zend_compile.c 258 行
A sample

•   Opcodes
A sample

•   Zend_execute       zend.c 594 行
     –   Zend_execute => execute
•   execute zend_vm_execute.h 34 行

         ZEND_API void execute(zend_op_array *op_array TSRMLS_DC)


•   Generate Output
•   Return to Apache Server process
•   Server send Responds Text to Client.
Now We Can….

•   1, 服务器的 Access log 没有任何输出
•   2, 隐藏 PHP 文件类型
•   3, PHP 出错的阶段
•   4, 编写 PHP 扩展
•   5, …
Documents

•   《 Apache Server 源代码分析》
•   《 Writing Apache Modules with Perl and C 》
•   《 Extending and Embedding PHP 》
•   《 PHP 手册》:“ Zend API :深入 PHP 内核”
•    http://blog.csdn.net/laruence
谢谢大家!

More Related Content

What's hot

Directory Traversal & File Inclusion Attacks
Directory Traversal & File Inclusion AttacksDirectory Traversal & File Inclusion Attacks
Directory Traversal & File Inclusion Attacks
Raghav Bisht
 
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ BehaviourWAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
Soroush Dalili
 
Rest API Security
Rest API SecurityRest API Security
Rest API Security
Stormpath
 
OWASP AppSecCali 2015 - Marshalling Pickles
OWASP AppSecCali 2015 - Marshalling PicklesOWASP AppSecCali 2015 - Marshalling Pickles
OWASP AppSecCali 2015 - Marshalling Pickles
Christopher Frohoff
 
Polymorphism in C++
Polymorphism in C++Polymorphism in C++
Polymorphism in C++
Rabin BK
 
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 EditionGoing Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
Soroush Dalili
 
REST API Design
REST API DesignREST API Design
REST API Design
Devi Kiran G
 
Host Header injection - Slides
Host Header injection - SlidesHost Header injection - Slides
Host Header injection - Slides
Amit Dubey
 
Deep dive into ssrf
Deep dive into ssrfDeep dive into ssrf
Oops in PHP
Oops in PHPOops in PHP
Oops in PHP
Mindfire Solutions
 
Pentesting ReST API
Pentesting ReST APIPentesting ReST API
Pentesting ReST API
Nutan Kumar Panda
 
Pentester's Mindset! - Ravikumar Paghdal
Pentester's Mindset! - Ravikumar PaghdalPentester's Mindset! - Ravikumar Paghdal
Pentester's Mindset! - Ravikumar Paghdal
NSConclave
 
PHP for Adults: Clean Code and Object Calisthenics
PHP for Adults: Clean Code and Object CalisthenicsPHP for Adults: Clean Code and Object Calisthenics
PHP for Adults: Clean Code and Object Calisthenics
Guilherme Blanco
 
Derbycon - Passing the Torch
Derbycon - Passing the TorchDerbycon - Passing the Torch
Derbycon - Passing the Torch
Will Schroeder
 
Building Better Backdoors with WMI - DerbyCon 2017
Building Better Backdoors with WMI - DerbyCon 2017Building Better Backdoors with WMI - DerbyCon 2017
Building Better Backdoors with WMI - DerbyCon 2017
Alexander Polce Leary
 
Frans Rosén Keynote at BSides Ahmedabad
Frans Rosén Keynote at BSides AhmedabadFrans Rosén Keynote at BSides Ahmedabad
Frans Rosén Keynote at BSides Ahmedabad
Security BSides Ahmedabad
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
Taha Malampatti
 

What's hot (20)

Directory Traversal & File Inclusion Attacks
Directory Traversal & File Inclusion AttacksDirectory Traversal & File Inclusion Attacks
Directory Traversal & File Inclusion Attacks
 
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ BehaviourWAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
WAF Bypass Techniques - Using HTTP Standard and Web Servers’ Behaviour
 
Rest API Security
Rest API SecurityRest API Security
Rest API Security
 
OWASP AppSecCali 2015 - Marshalling Pickles
OWASP AppSecCali 2015 - Marshalling PicklesOWASP AppSecCali 2015 - Marshalling Pickles
OWASP AppSecCali 2015 - Marshalling Pickles
 
Polymorphism in C++
Polymorphism in C++Polymorphism in C++
Polymorphism in C++
 
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 EditionGoing Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
Going Beyond Microsoft IIS Short File Name Disclosure - NahamCon 2023 Edition
 
REST API Design
REST API DesignREST API Design
REST API Design
 
Host Header injection - Slides
Host Header injection - SlidesHost Header injection - Slides
Host Header injection - Slides
 
Deep dive into ssrf
Deep dive into ssrfDeep dive into ssrf
Deep dive into ssrf
 
Oops in PHP
Oops in PHPOops in PHP
Oops in PHP
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
 
Php Ppt
Php PptPhp Ppt
Php Ppt
 
Pentesting ReST API
Pentesting ReST APIPentesting ReST API
Pentesting ReST API
 
Pentester's Mindset! - Ravikumar Paghdal
Pentester's Mindset! - Ravikumar PaghdalPentester's Mindset! - Ravikumar Paghdal
Pentester's Mindset! - Ravikumar Paghdal
 
PHP for Adults: Clean Code and Object Calisthenics
PHP for Adults: Clean Code and Object CalisthenicsPHP for Adults: Clean Code and Object Calisthenics
PHP for Adults: Clean Code and Object Calisthenics
 
Sql injection
Sql injectionSql injection
Sql injection
 
Derbycon - Passing the Torch
Derbycon - Passing the TorchDerbycon - Passing the Torch
Derbycon - Passing the Torch
 
Building Better Backdoors with WMI - DerbyCon 2017
Building Better Backdoors with WMI - DerbyCon 2017Building Better Backdoors with WMI - DerbyCon 2017
Building Better Backdoors with WMI - DerbyCon 2017
 
Frans Rosén Keynote at BSides Ahmedabad
Frans Rosén Keynote at BSides AhmedabadFrans Rosén Keynote at BSides Ahmedabad
Frans Rosén Keynote at BSides Ahmedabad
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 

Similar to The Php Life Cycle

Phpをいじり倒す10の方法
Phpをいじり倒す10の方法Phpをいじり倒す10の方法
Phpをいじり倒す10の方法Moriyoshi Koizumi
 
Cli the other sapi pbc11
Cli the other sapi pbc11Cli the other sapi pbc11
Cli the other sapi pbc11
Combell NV
 
CLI, the other SAPI phpnw11
CLI, the other SAPI phpnw11CLI, the other SAPI phpnw11
CLI, the other SAPI phpnw11
Combell NV
 
Cli the other SAPI confoo11
Cli the other SAPI confoo11Cli the other SAPI confoo11
Cli the other SAPI confoo11
Combell NV
 
Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )Joseph Scott
 
Quick tour of PHP from inside
Quick tour of PHP from insideQuick tour of PHP from inside
Quick tour of PHP from inside
julien pauli
 
Php engine
Php enginePhp engine
Php engine
julien pauli
 
PHP Internals and Virtual Machine
PHP Internals and Virtual MachinePHP Internals and Virtual Machine
PHP Internals and Virtual Machine
julien pauli
 
Php opcodes sep2008
Php opcodes sep2008Php opcodes sep2008
Php opcodes sep2008bengiuliano
 
Create your own PHP extension, step by step - phpDay 2012 Verona
Create your own PHP extension, step by step - phpDay 2012 VeronaCreate your own PHP extension, step by step - phpDay 2012 Verona
Create your own PHP extension, step by step - phpDay 2012 Verona
Patrick Allaert
 
Debugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionDebugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 Version
Ian Barber
 
[2012 CodeEngn Conference 06] pwn3r - Secuinside 2012 CTF 예선 문제풀이
[2012 CodeEngn Conference 06] pwn3r - Secuinside 2012 CTF 예선 문제풀이[2012 CodeEngn Conference 06] pwn3r - Secuinside 2012 CTF 예선 문제풀이
[2012 CodeEngn Conference 06] pwn3r - Secuinside 2012 CTF 예선 문제풀이
GangSeok Lee
 
PHP & Performance
PHP & PerformancePHP & Performance
PHP & Performance
毅 吕
 
DPC 2012 : PHP in the Dark Workshop
DPC 2012 : PHP in the Dark WorkshopDPC 2012 : PHP in the Dark Workshop
DPC 2012 : PHP in the Dark WorkshopJeroen Keppens
 
Symfony 2 (PHP Quebec 2009)
Symfony 2 (PHP Quebec 2009)Symfony 2 (PHP Quebec 2009)
Symfony 2 (PHP Quebec 2009)Fabien Potencier
 
Performance tuning with zend framework
Performance tuning with zend frameworkPerformance tuning with zend framework
Performance tuning with zend framework
Alan Seiden
 
Quality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStormQuality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStorm
Michelangelo van Dam
 
Debugging: Rules & Tools
Debugging: Rules & ToolsDebugging: Rules & Tools
Debugging: Rules & Tools
Ian Barber
 
"Развитие ветки PHP-7"
"Развитие ветки PHP-7""Развитие ветки PHP-7"
"Развитие ветки PHP-7"
Badoo Development
 
Tips
TipsTips
Tipsmclee
 

Similar to The Php Life Cycle (20)

Phpをいじり倒す10の方法
Phpをいじり倒す10の方法Phpをいじり倒す10の方法
Phpをいじり倒す10の方法
 
Cli the other sapi pbc11
Cli the other sapi pbc11Cli the other sapi pbc11
Cli the other sapi pbc11
 
CLI, the other SAPI phpnw11
CLI, the other SAPI phpnw11CLI, the other SAPI phpnw11
CLI, the other SAPI phpnw11
 
Cli the other SAPI confoo11
Cli the other SAPI confoo11Cli the other SAPI confoo11
Cli the other SAPI confoo11
 
Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )Anatomy of a PHP Request ( UTOSC 2010 )
Anatomy of a PHP Request ( UTOSC 2010 )
 
Quick tour of PHP from inside
Quick tour of PHP from insideQuick tour of PHP from inside
Quick tour of PHP from inside
 
Php engine
Php enginePhp engine
Php engine
 
PHP Internals and Virtual Machine
PHP Internals and Virtual MachinePHP Internals and Virtual Machine
PHP Internals and Virtual Machine
 
Php opcodes sep2008
Php opcodes sep2008Php opcodes sep2008
Php opcodes sep2008
 
Create your own PHP extension, step by step - phpDay 2012 Verona
Create your own PHP extension, step by step - phpDay 2012 VeronaCreate your own PHP extension, step by step - phpDay 2012 Verona
Create your own PHP extension, step by step - phpDay 2012 Verona
 
Debugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionDebugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 Version
 
[2012 CodeEngn Conference 06] pwn3r - Secuinside 2012 CTF 예선 문제풀이
[2012 CodeEngn Conference 06] pwn3r - Secuinside 2012 CTF 예선 문제풀이[2012 CodeEngn Conference 06] pwn3r - Secuinside 2012 CTF 예선 문제풀이
[2012 CodeEngn Conference 06] pwn3r - Secuinside 2012 CTF 예선 문제풀이
 
PHP & Performance
PHP & PerformancePHP & Performance
PHP & Performance
 
DPC 2012 : PHP in the Dark Workshop
DPC 2012 : PHP in the Dark WorkshopDPC 2012 : PHP in the Dark Workshop
DPC 2012 : PHP in the Dark Workshop
 
Symfony 2 (PHP Quebec 2009)
Symfony 2 (PHP Quebec 2009)Symfony 2 (PHP Quebec 2009)
Symfony 2 (PHP Quebec 2009)
 
Performance tuning with zend framework
Performance tuning with zend frameworkPerformance tuning with zend framework
Performance tuning with zend framework
 
Quality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStormQuality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStorm
 
Debugging: Rules & Tools
Debugging: Rules & ToolsDebugging: Rules & Tools
Debugging: Rules & Tools
 
"Развитие ветки PHP-7"
"Развитие ветки PHP-7""Развитие ветки PHP-7"
"Развитие ветки PHP-7"
 
Tips
TipsTips
Tips
 

More from Xinchen Hui

A brief to PHP 7.3
A brief to PHP 7.3A brief to PHP 7.3
A brief to PHP 7.3
Xinchen Hui
 
PHP7.1 New Features & Performance
PHP7.1 New Features & PerformancePHP7.1 New Features & Performance
PHP7.1 New Features & Performance
Xinchen Hui
 
The secret of PHP7's Performance
The secret of PHP7's Performance The secret of PHP7's Performance
The secret of PHP7's Performance
Xinchen Hui
 
PHP7 - For Its Best Performance
PHP7 - For Its Best PerformancePHP7 - For Its Best Performance
PHP7 - For Its Best Performance
Xinchen Hui
 
A History of PHP
A History of PHPA History of PHP
A History of PHP
Xinchen Hui
 
High Performance Solution for PHP7
High Performance Solution for PHP7High Performance Solution for PHP7
High Performance Solution for PHP7
Xinchen Hui
 
PHP7 - The New Engine for old good train
PHP7 - The New Engine for old good trainPHP7 - The New Engine for old good train
PHP7 - The New Engine for old good train
Xinchen Hui
 
微博Lamp性能优化之路(2014)
微博Lamp性能优化之路(2014)微博Lamp性能优化之路(2014)
微博Lamp性能优化之路(2014)
Xinchen Hui
 
Weibo lamp improvements
Weibo lamp improvementsWeibo lamp improvements
Weibo lamp improvements
Xinchen Hui
 
Php 5.4 performance
Php 5.4 performancePhp 5.4 performance
Php 5.4 performance
Xinchen Hui
 
China PHP Technology Summit 2011 ppt
China PHP Technology Summit 2011 pptChina PHP Technology Summit 2011 ppt
China PHP Technology Summit 2011 pptXinchen Hui
 
Php performance
Php performancePhp performance
Php performance
Xinchen Hui
 

More from Xinchen Hui (12)

A brief to PHP 7.3
A brief to PHP 7.3A brief to PHP 7.3
A brief to PHP 7.3
 
PHP7.1 New Features & Performance
PHP7.1 New Features & PerformancePHP7.1 New Features & Performance
PHP7.1 New Features & Performance
 
The secret of PHP7's Performance
The secret of PHP7's Performance The secret of PHP7's Performance
The secret of PHP7's Performance
 
PHP7 - For Its Best Performance
PHP7 - For Its Best PerformancePHP7 - For Its Best Performance
PHP7 - For Its Best Performance
 
A History of PHP
A History of PHPA History of PHP
A History of PHP
 
High Performance Solution for PHP7
High Performance Solution for PHP7High Performance Solution for PHP7
High Performance Solution for PHP7
 
PHP7 - The New Engine for old good train
PHP7 - The New Engine for old good trainPHP7 - The New Engine for old good train
PHP7 - The New Engine for old good train
 
微博Lamp性能优化之路(2014)
微博Lamp性能优化之路(2014)微博Lamp性能优化之路(2014)
微博Lamp性能优化之路(2014)
 
Weibo lamp improvements
Weibo lamp improvementsWeibo lamp improvements
Weibo lamp improvements
 
Php 5.4 performance
Php 5.4 performancePhp 5.4 performance
Php 5.4 performance
 
China PHP Technology Summit 2011 ppt
China PHP Technology Summit 2011 pptChina PHP Technology Summit 2011 ppt
China PHP Technology Summit 2011 ppt
 
Php performance
Php performancePhp performance
Php performance
 

Recently uploaded

Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 

Recently uploaded (20)

Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 

The Php Life Cycle

  • 1. The PHP Lifecycle Yahoo! . 惠新宸 Tel : 86111 Mail: laruence@yahoo.com.cn
  • 2. Summary • B/S(HTTP Request Cycle) • Apache Life Cycle • Apache Parse Request Cycle • PHP Life Cycle • Cooperating with Apache • PHP Parse/Execute Process • Now We Can… Linux/Unix + Apache 1.3x + PHP 5.x
  • 3. B/S 1. Client Request 2. Server Parse Requst and Send Response 3. Client interpret Responded Text/HTML/Json etc…
  • 6. PHP Life Cycle • In command line mode(CLI)
  • 7. PHP Life Cycle con’t • PHP_MODULE_ENTRY(php_mysql.c 215 行 )
  • 8. PHP Life Cycle con’t • PHP_MINIT_FUNCTION(php_mysql.c 378 行 )
  • 9. PHP Life Cycle con’t • PHP_RINIT_FUNCTION(php_mysql.c 473 行 )
  • 10. PHP Life Cycle con’t • PHP_SHUTDOWNS(php_mysql.c 403 行 )
  • 11. PHP Life Cycle con’t • In DSO mode – Single process
  • 12. PHP Life Cycle con’t • In DSO mode – Multiprocess
  • 13. PHP Life Cycle con’t • In CGI mode – Multithreaded
  • 14. Cooperation • Apache 1.3x + PHP 5.x in DSO mode • Dynamic Shared Objects (DSO) – mod_dso • src/modules/standard/mod_so.c 347 行
  • 15. Cooperation con’t • Php Module 注册 Handler – mod_php5.c 963 行
  • 16. Cooperation con’t • Php Module 注册 Handler – mod_php5.c 987 行
  • 19. PHP Parse/Execute Process con’t • Scan(lex) – Zend/zend_language_scanner.c 3047 行 ZEND_API zend_op_array *compile_file(zend_file_handle *file_handle, int type TSRMLS_DC){ retval = op_array; …. return retval;} – Zend/zend_language_scanner.l T_OPEN_TAG: '<?php ' = <?php T_LNUMBER: '1' $sum = 1 + 2; + echo “1+2=“.$sum; T_LNUMBER: '2' ?> T_ECHO: 'echo'' T_CONSTANT_ENCAPSED_STRI NG: ''1+2=''. T_CLOSE_TAG: '?>'
  • 20. PHP Parse/Execute Process con’t • Parse/Complie(yacc) – zend_language_parser.y T_OPEN_TAG: '<?php ' = Opcode Op1 Op2 Result T_LNUMBER: '1' ADD 1 2 $tmp0 + ASSIGN $cv0(sum) $tmp0 $var1 T_LNUMBER: '2' CONCAT '1+2=' $cv0(sum) $tmp2 T_ECHO: 'echo'' ECHO $tmp2 T_CONSTANT_ENCAPSED_STRI RETURN 1 NG: ''1+2=''. T_CLOSE_TAG: '?>'
  • 21. PHP Parse/Execute Process con’t • Execute – Zend/zend_execute.c void (*zend_execute) (zend_op_array *op_array TSRMLS_DC); • Zend_op_array – Zend/zend_compile.h struct zend_op{ opcode_handler_t handler; znoderesult; znodeop1; znodeop2; ulongextended_value; uintlineno; zend_ucharopcode; };
  • 22. PHP Parse/Execute Process con’t • Execute – Zend/zend_opcode.c 428 行
  • 23. A sample • Clien Request
  • 24. A sample • http_main.c 8053 – main() call ap_main • ap_main => REALMAIN – REALMAIN(argc, argv) – http_main.c • child_main – Call child_sub_main 6134 • chile_sub_main – loop worker – call ap_process_request(r) on request • http_reqeust.c 1308 • ap_process_request – call process_request_internal • process_request_internal – call ap_invoke_handler Application/x-httpd-php -> send_parsed_php
  • 25. A sample • Server Pares – URI • Filename -> /test/index.php – User Auth – … – MIME type Check • application/x-httpd-http – Call handler • send_parsed_php(request_rec *) • Zend_execute_script(…..request_rec->filename);
  • 27. A sample • Index.php <?php echo 2+3; ?>
  • 28. A sample • Zend_language_scanner.l 362 行 • Zend_language_parse.c 62 行
  • 29. A sample • Parser – Zend_language_parse.y – Zend_compile.c 258 行
  • 30. A sample • Opcodes
  • 31. A sample • Zend_execute zend.c 594 行 – Zend_execute => execute • execute zend_vm_execute.h 34 行 ZEND_API void execute(zend_op_array *op_array TSRMLS_DC) • Generate Output • Return to Apache Server process • Server send Responds Text to Client.
  • 32. Now We Can…. • 1, 服务器的 Access log 没有任何输出 • 2, 隐藏 PHP 文件类型 • 3, PHP 出错的阶段 • 4, 编写 PHP 扩展 • 5, …
  • 33. Documents • 《 Apache Server 源代码分析》 • 《 Writing Apache Modules with Perl and C 》 • 《 Extending and Embedding PHP 》 • 《 PHP 手册》:“ Zend API :深入 PHP 内核” • http://blog.csdn.net/laruence