4 ms·
That"your app gets initialized and torn down for every request" is _the_ best feature of PHP. This may sound strange first, but it's true. With web applications
by tpetry 5y ago
That"your app gets initialized and torn down for every request" is _the_ best feature of PHP. This may sound strange first, but it's true. With web applications written in any other language you have a stateful server running all the time with the following "problems":
* If you have a memory leak your complete server will get killed some time later when running out of memory
* If you have a bug which crashes your web server every running request is killed
* You get all the hard-to-find concurrency bugs when multiple requests concurrently can access some objects.
With PHP's model of (1) initializing and destroying all the state on every request and (2) every request running in it's completely isolated virtual space you don't have any of these problems.
And if you really want to have a long-running server with shared space you can have that too, take a look at Laravel Octane.