• DevOps
    Case Study

    How we built a resilient multi-account, multi-cloud solution for a Health Tech service provider!

    READ CASESTUDY
    icon

    24/7 DevOps as a Service

    Round-the-clock DevOps for uninterrupted efficiency.

    icon

    Infrastructure as a Code

    Crafting infrastructure with ingenious code.

    icon

    CI/CD Pipeline

    Automated CI/CD pipeline for seamless deployments.

    icon

    DevSecOps

    Integrated security in continuous DevOps practices.

    icon

    Hire DevOps Engineers

    Level up your team with DevOps visionaries.

    icon

    Consulting Services

    Navigate success with expert DevOps consulting.

  • TechOps
    Case Study

    How we built a scalable Odoo solution for a Travel Tech service provider!

    READ CASESTUDY

    WEB HOSTING SUPPORT

    icon

    HelpDesk Support

    Highly skilled 24/7 HelpDesk Support

    icon

    Product Support

    Boost your product support with our expertise.

    MANAGED SERVICES

    icon

    Server Management

    Don’t let server issues slow you down. Let us manage them for you.

    icon

    Server Monitoring

    Safeguard your server health with our comprehensive monitoring solutions.

    STAFF AUGMENTATION

    icon

    Hire an Admin

    Transform your business operations with our expert administrative support.

    icon

    Hire a Team

    Augment your workforce with highly skilled professionals from our diverse talent pool.

  • CloudOps
    Case Study

    How we helped a Private Deemed University in India, save US $3500/m on hosting charges!

    READ CASESTUDY
    icon

    AWS Well Architected Review

    Round-the-clock for uninterrupted efficiency

    icon

    Optimize

    Efficient CloudOps mastery for seamless cloud management

    icon

    Manage

    Automated CI/CD pipeline for seamless deployments

    icon

    Migrate

    Upgrade the journey, Migrate & Modernize seamlessly

    icon

    Modernize

    Simplify compliance complexities with our dedicated services

    icon

    FinOps as a Service

    FinOps as a Service

  • SecOps
    Case Study

    How we built a scalable Odoo solution for TravelTech service provider!

    READ CASESTUDY
    icon

    VAPT

    Vulnerability Assessment and Penetration Testing

    icon

    Source Code Review

    Ensuring source code security ans safe practices to reduce risks

    icon

    Security Consultation

    On demand services for improving server security

    icon

    System Hardening

    Reduced vulnerability and proactive protection

    icon

    Managed SoC

    Monitors and maintains system security. Quick response on incidents.

    icon

    Compliance as a Service

    Regulatory compliance, reduced risk

  • Insights
    Case Study

    How we helped a Private Deemed University in India, save US $3,500/m on hosting charges!

    READ CASESTUDY
    icon

    Blog

    Explore our latest articles and insights

    icon

    Case Studies

    Read about our client success stories

    icon

    Flipbook

    Explore our latest Flipbook

    icon

    Events

    Join us at upcoming events and conferences

    icon

    Webinars

    Watch our educational webinar series

  • Our Story
  • Contact Us

Interested to collaborate?

Get in touch with us!

Ready to elevate your business with certified cloud expertise? Contact us today to learn how our team can help you leverage cloud technology to drive growth, streamline operations, and enhance security.

  • AWSAWS
  • Azure CloudAzure Cloud
  • Google CloudGoogle Cloud
  • Akamai CloudAkamai Cloud
  • OVHOVH
  • Digital OceanDigital Ocean
  • HetznerHetzner
  • Kubernetes Consultancy Services
  • K8s & Cloud native Solutions
  • 24/7 Infrastructure Monitoring
  • DevOps as a Service
  • Cloud CI/CD Solutions
  • White Labeled MSP Support
  • Our story
  • Life@SupportSages
  • Insights
  • Careers
  • Events
  • Contact Us

Connect with us!


LinkedInFacebookXInstagramYouTube

aws partneraws advanced partner
SupportSages

Copyright © 2008 – 2026 SupportSages Pvt Ltd. All Rights Reserved.
Privacy PolicyLegal TermsData ProtectionCookie Policy
Php – behind the scenes

Php – behind the scenes

George K.

  • 4 min read
Php – behind the scenes

Generating audio, please wait...

Preface:

My previous blogs were about how we can install php in various format. Here I am trying to elaborate php working and the steps involved  during the phase. You may wonder why such an understanding of PHP working is necessary for a sysadmin job. To be honest , I was quite confused what is extensions, Zend engine and the way the total  process takes.

Thanks for the excellent post  by Abhinav Singh , now I  know  how php works 🙂

The PHP Structure

The  PHP binary consists of three layers Core PHP, Zend Engine and Extension Layer.

Core PHP :

PHP handles communication with, and bindings to, the SAPI layer (Server Application Programming Interface, also commonly used to refer to the host environment – Apache, IIS, CLI, CGI, etc).  It handles the requests, file streams, error handling and other such operations.  Due to  low level operations it performs , it is identical with a Kernel in the OS.

Zend Engine:

ZE acts as an interpreter between the user and the Core PHP. It converts the php scripts to the machine understandable format ie opcode generation and then transfer it to   CorePHP and converts the result to human readable form. ZE handles parsing a human-readable script into machine-readable tokens, and then executing those tokens within a process space. ZE also handles memory management, variable scope, and dispatching function calls

Extensions

Extensions are a bunch of functions, classes, streams made available to the PHP scripts, which can be used to perform certain tasks. For example, we need mysql extension to connect to MySQL database using PHP.

The Process

Now let as see how a php scripts work. For the sake of convenience here I assume that php is compiled as an apache module ( SAPI i.e. a Server API) using mod_php.so.

When apache is invoked , every child process will invoke a php interpreter with it.

The php  initialization takes place with the following steps

PHP begins by initializing its core subsystems. Towards the end of this start-up routine, it loads the code for each extension and calls their Module Initialization routine . This gives each extension a chance to initialize internal variables, allocate resources, register resource handlers, and register its functions with ZE, so that if a script calls one of those functions, ZE knows which code to execute. This process is called MINT or Module Initialization

Next, PHP waits for the SAPI layer to request a page to be processed. Once the  request comes in, PHP begins by asking ZE to setup an environment for the script to run in, then calls each extension’s Request Initialization function. After this the extension  gets the chance to set up specific environment variables, allocate request specific resources, or perform other tasks such as auditing  .

Once the request is initialized, ZE takes over by translating the PHP script into tokens, and finally to opcodes which it can step through and execute. Should one of these opcodes require an extension function to be called, ZE will bundle up the arguments for that function, and temporarily give over control until it completes.

After a script has finished executing, PHP calls the Request Shutdown function of each extension to perform any last minute cleanup (such as saving session variables to disk). Next, ZE performs a clean-up process (known as garbage collection) which effectively performs an  on every variable used during the previous request.

Once completed, PHP waits for the SAPI to either request another document or signal a shut down. During shutdown, PHP again cycles through each extension calling their Module Shutdown functions, and finally shuts down its own core subsystems.

I believe this should  give you some insights about php working
Further readings

https://www.supportsages.com/2010/06/php-basics/

https://www.supportsages.com/2010/06/php-cgi/

https://www.supportsages.com/2010/06/mod_php-explained/

 

  • Apache
  • cPanel
  • General
  • Howtos
  • Linux

.htaccess based mod_rewrite not working with Godaddy ?

.htaccess based mod_rewrite not working with Godaddy ?
  • Apache
  • General
  • Howtos
  • Linux
logo

/proc explained

/proc explained
  • Linux
logo

A story of Ubuntu – I am what I am because of who we all are :)

A story of Ubuntu – I am what I am because of who we all are :)
  • General
  • Training
logo

Account Creation: Sorry, a mysql user with the name x already exists.

Account Creation:  Sorry, a mysql user with the name x already exists.
  • MySQL
  • Troubleshooting
logo

Posts by George K.

George started his career in web hosting and Linux technical support in the year 2004 and is with SupportSages since 2009. He has keen interest in server optimizations, custom security solutions, hacked server recovery, cyber forensic and high availability fail over system design and implementation. George loves long drives and is passionate about art and literature.