Architecture Diagram of PHP based web applications

Now lets put all these together and see how do they work actually. An Architecture Diagram is a logical diagram that shows how each of the components in a system is connected with each other and how are the data flowing between. If we draw architecture diagram for a typical PHP based web application it will be like the below diagram.


Architecture Diagram

Lets now discuss over it little more. The numbers I used below beside the Label names following 1 for Request flow and 2 for response flow.


A1: First user accessed the website through browser. That means user types the URL of the website in browser and hit go.

B1: The page request on browser will reach to the Web Server (Apache).

C: Web server will collect that requested page (HTML or PHP or Image file etc) from its document root. (In our example it will be www folder in WAMP. You will see it in next one)

B2: Now if it is a static element like HTML , CSS , image file or Java Script file then Apache will send it directly to browser.

A2: And Browser will render it to user on screen

D1 : If it is a PHP file then Apache sends the content of the file to PHP Interpreter. PHP interpreter interprets the PHP code and executes it. if DB operation is required it performs the same (E)

D2: PHP Interpreter generates output (if the PHP code is to generate any output) and sends to Apache

B2: Apache sends that content to browser

A2: Browser renders it to users' screen

All static components like HTML, CSS files ,Image Files , Java Scripts etc doesn't need interpreter. Our web browsers are built to render them and display on screen properly. That is why if user requests for these kind of components Apache collects them from Document root and sends back to Browser directly.

Only if requested page is a PHP page Apache will send it to PHP interpreter to get it translated and executed.

That is why though those listed static components reside on Server we will consider them as part of User Interface and as they get rendered at user's browser we may refer them as Client side components. In web technology Browsers are Client terminals.

And for similar reason we will refer PHP files as Server side components as they have dependencies on another Server Side component PHP Interpreter and cannot be executed only on browsers.
Now let me explain the keywords of the definition as you will be able to understand them better

1. PHP files are kept on Server (in Document root)  - Server Side
2. PHP Interpreter interprets PHP language and executes instructions as per code.It does not need compilation( This is way deep and different topic to discuss in a separate forum) - Scripting language


2 comments: