Hacker News new | ask | show | jobs
by dakiol 297 days ago
The one thing I don't like about PHP is that the whole application is bootstraped (and autoloading and the configuration is re-evaluated) in every single http request. Sure thing there's cache and all, but it just doesn't feel right (compared, to, for instance, an http server written in golang)
5 comments

There are well documented and production-ready libraries that you can use to run your own servers with PHP alone, no need for fpm or mod_php. PHP's JIT is pretty impressive and you would be blown away by the results.

https://reactphp.org/

https://www.php.net/manual/en/book.ev.php

https://bitbucket.org/osmanov/pecl-event

https://www.workerman.net/

It doesn't have to be. Some PHP runtimes allow an application to run in a mode where a single script execution processes multiple HTTP requests:

https://frankenphp.dev/docs/worker/

This is one of the best things about PHP IMO. It makes it very easy to scale out.
It also makes it much easier to debug and forces the complexity down.
Yup. No shared state by default.
This is one of the things I do like about PHP.

Intrinsically minimized state (to a certain degree).

You're right. It's a completely asinine approach. Especially when PHP itself is used as a templating language.

And solutions that try to fix this (custom templating engines, runtimes that run the whole thing inside a continuous PHP process) are simply putting lipstick on a pig.

The solution is to use a language that wasn't originally called "Personal HomePage"