PHP Execution Model

Discussions focus on PHP's server integration (mod_php, PHP-FPM) versus CGI, highlighting its stateless request handling, performance advantages, and lack of app servers compared to frameworks like Ruby on Rails or Python.

📉 Falling 0.4x Web Development
2,316
Comments
20
Years Active
5
Top Authors
#5346
Topic ID

Activity Over Time

2007
10
2008
31
2009
48
2010
102
2011
141
2012
179
2013
167
2014
129
2015
81
2016
127
2017
97
2018
96
2019
153
2020
180
2021
148
2022
203
2023
145
2024
147
2025
128
2026
4

Keywords

PHP JS index.php FPM ProcessWire XML MVC GET CGI TLS php cgi request server http web apache frameworks webserver application

Sample Comments

tored Aug 23, 2021 View on HN

This is basically what PHP is. PHP can be deployed in several ways, CGI, FCGI or as threaded module in apache, but that rarely matters from the perspective of the programmer, the code will work the same regardless what you put in front of it but still keep CGI-like execution. This is why PHP is a perfect match for the web.

greggman7 Jan 13, 2025 View on HN

PHP integrates with the server. It does not have the spawn a new process per request like CGI

bluejekyll Oct 22, 2016 View on HN

PHP can only be used serverside, no? Can't write single page apps.

voidr Feb 16, 2025 View on HN

Nobody runs PHP in CGI mode, either they go with libapache2_mod_php, where Apache itself does the work or PHP-FPM with Nginx.Either way you are not going to pay for the PHP process startup cost.PHP can also cache the interpretations of files so you avoid that cost as well.And frameworks usually have their own usually file-based caching mechanism.At the end of the day it's still going to have some costs compared to a single application server model, but for most web apps it'

alexhakawy Nov 24, 2016 View on HN

cause PHP isn't magic like Ruby on Rails.

greggman Jan 4, 2015 View on HN

This doesn't seem to replace PHP whatsoever.I thought PHP didn't run as CGI, shelling to a separate program with every request. It runs, in nearly all installations, as a plugin, saving the overhead of spawning a new program.That's just one of the many reasons it did so well back it the day because it allowed a server to handle far more requests than CGI based stuff.

swiley Aug 16, 2021 View on HN

Php needs an application server as well.

brendano Apr 11, 2012 View on HN

PHP is much better than CGI, because it doesn't have to load an interpreter and all libraries per request -- they were loaded at server startup time. This is why all serious web frameworks don't use CGI. But PHP avoids the administrative/stability problems of persistent servers -- Python, Java, Ruby -- by disallowing state across requests.I think, because PHP servers are so stable, that's part of why they're so common on shared web hosts. For example, running a WSGI server is much m

antirez May 29, 2007 View on HN

Maybe they use PHP like a better version of server side includes. For this RoR is probably an overkill.

strictfp May 18, 2019 View on HN

No, but PHP does not get in your way unlike many other web frameworks.