Live data from Hacker News

An Internet of PHP

timotijhof.net

71–80 of 333 posts

Re: An Internet of PHP

#71

I like PHP, one issue which I face with PHP though is, that it is difficult to create a self-contained docker image. With node.js or java spring boot i can build an application with an http endpoint and create a single docker image with all included easily. With php I need 2 distinct containers, e.g., nginx, php-fpm and the code mounted on a volume to the the containers. So it seems to be more difficult for setup and…

PHP has had a built-in web server since version 5.

People use Apache or nginx because they want to, but because they need to.

Re: An Internet of PHP

#72

I like PHP, one issue which I face with PHP though is, that it is difficult to create a self-contained docker image. With node.js or java spring boot i can build an application with an http endpoint and create a single docker image with all included easily. With php I need 2 distinct containers, e.g., nginx, php-fpm and the code mounted on a volume to the the containers. So it seems to be more difficult for setup and…

You can't have nginx and php in the same container?

Does not docker recommend a single process story? Nginx is typically a reverse proxy in front of an application server.

Re: An Internet of PHP

#73
post #28

At the end of the day if your software works and users like it, does the programming language even matter?

Maybe not for the user, at least not directly, but developer experience is something to optimise for. PHP is also the one language whose choice can make an impact on users' experience, since its shared-nothing (sans caches) runtime model is almost CGI-like and can, in my experience, lead to higher latency, as each request simply does more. Maybe some experienced PHP devs can tell me how they combat this?

> since its shared-nothing (sans caches) runtime model is almost CGI-like and can, in my experience, lead to higher latency, as each request simply does more. Maybe some experienced PHP devs can tell me how they combat this?

I mean, you kind of answered your own question - they use caches like apcu or memcached. Apcu is just shared memory so its basically ends up being very similar to languages that don't do shared nothing.

Re: An Internet of PHP

#74

Earlier quoted context omitted.

Not sure why it is downvoted as this is true. That said it is more to do with shared hosts culture choosing PHP than PHP itself. (They tend to support Ruby and Node but not as well)

PHP is also pretty easy to support for shared hosting, as what they essentially need is just an Apache module (+ nginx probably), some clever filesystem permissions and they're done. For node, Python, etc, you actually need to keep the application servers running, which has to stay running even when they're completely idle. So I think PHP is a natural choice for shared hosting for those reasons too.

This is exactly to the reason why PHP and before perl are successful in this space.

When you extrapolate that to modern tech, you could create a shared hoster with a configured reverse proxy and per customer docker images.

But that is so much expensive to build, operate and bill than an apache. And looks very close to AWS and friends.

Re: An Internet of PHP

#75

I like PHP, one issue which I face with PHP though is, that it is difficult to create a self-contained docker image. With node.js or java spring boot i can build an application with an http endpoint and create a single docker image with all included easily. With php I need 2 distinct containers, e.g., nginx, php-fpm and the code mounted on a volume to the the containers. So it seems to be more difficult for setup and…

Yes, the apache[0] image will do what you want

[0] https://github.com/docker-library/php/blob/1c4b255f3e5ab610c...

Re: An Internet of PHP

#76
post #71

I like PHP, one issue which I face with PHP though is, that it is difficult to create a self-contained docker image. With node.js or java spring boot i can build an application with an http endpoint and create a single docker image with all included easily. With php I need 2 distinct containers, e.g., nginx, php-fpm and the code mounted on a volume to the the containers. So it seems to be more difficult for setup and…

PHP has had a built-in web server since version 5. People use Apache or nginx because they want to, but because they need to.

I think using the php built-in webserver is not an option for a production setting.

Re: An Internet of PHP

#77

I like PHP, one issue which I face with PHP though is, that it is difficult to create a self-contained docker image. With node.js or java spring boot i can build an application with an http endpoint and create a single docker image with all included easily. With php I need 2 distinct containers, e.g., nginx, php-fpm and the code mounted on a volume to the the containers. So it seems to be more difficult for setup and…

I use RoadRunner for that purpose. It even has some amazing features you can enable as keeping the application loaded in memory between requests.

https://roadrunner.dev/

Re: An Internet of PHP

#79

I like PHP, one issue which I face with PHP though is, that it is difficult to create a self-contained docker image. With node.js or java spring boot i can build an application with an http endpoint and create a single docker image with all included easily. With php I need 2 distinct containers, e.g., nginx, php-fpm and the code mounted on a volume to the the containers. So it seems to be more difficult for setup and…

I don't really know what directed you to the nginx+fpm+volumes in the first place.

  FROM php:7.2-apache
  COPY src/ /var/www/html/
and this is it.

Re: An Internet of PHP

#80
post #38
post #33

Earlier quoted context omitted.

It’s like meeting someone in 2023 who hates Micro$oft WinBLOWZ. Have they been stuck in stasis for 20 years? What other values from the 9/11 era do they hang on to?

This reminds me of the sysadmin at a Greek university I once worked in back in 2009 or so. He had installed Linux at every one of the computer labs' computers. He'd changed the startup software to describe Windows as Windows UnProfessional. The default was Linux, and it would boot within 3 seconds unless you quickly changed it. Under Linux he'd included all the Gnome 2 window manager flash, including spinning cubes a…

I like the fun spirit of it. We do not have these people anymore.
Post reply on HN