Hacker News new | ask | show | jobs
by jread 1507 days ago
When did you last use PHP? It's not the PHP of 15 years ago. It scales fine when properly written and deployed.
1 comments

I didn't mean scalability in terms of performance, but scalability in terms of maintenance effort. It's easy to SCP some files in, but the moment you want atomic deployments, it gets unnecessarily interesting.
PHP is the only language I've set up production environments for, but I can't see any reason why it would be more complicated than other languages.

I have a PHP project that handles atomic deployments by pointing the web server at a symlink named "latest". New versions get deployed into their own folder in the "versions" folder, and then the "latest" symlink gets pointed to the new version. Super simple to set up, and as long as you delete old versions as you go (keeping, say 3 versions so you can roll back as necessary) that's pretty much all there is to it. This all gets triggered by a Gitlab CI workflow, so I can hit a button to deploy after merging changes.

Another PHP-focused way to handle this would be deploying into a new folder, then updating the nginx config to point to that folder and running `service nginx restart`.

You can also use one of the many other atomic deployment options that replace more than just the running code, at which point the only difference between deploying a PHP webapp and deploying a Java/Go/Rust webapp is what gets included in your new server/container when you build it.

That's my entire point: the increase in complexity is very non-linear. With Python, Go, or whatever else, you pay a slightly higher upfront price, and you get things like atomic deployments out of the box; that price is however almost immediately amortised by the de-facto requirement to set up HTTPS/ACME, etc.

With PHP it's easier to just get started, but you've already mentioned versions, symlinks, CI, etc - that's the non-linear increase in complexity, you have to add a lot more pieces to get good ROI. With Python or Go you can continue using SCP to deploy for as long as it suits your needs, because no code changes will be picked up until you restart the process. If you need rollbacks, e.g. Go doesn't need symlinks or versioned directories - the entire app is a single executable, so you can just keep copies of these. You pay for what you use, and the returns are more linear and immediate.

If you only have experience deploying PHP, I would sincerely recommend trying other languages/runtimes/frameworks, even if for no other reason than to learn from what the rest of the world is doing. For me, learning to deploy PHP correctly was also a horizon-broadening experience.

Atomic deployments with PHP is basically as simple as "git pull" in a temporary working directory and copying it to a release directory..
for your "personal blog" git pull can be used as deployment - don't forget to exclude the access to the .git directory in .htaccess ...

but for "serious" applications / deployment-routines this is never an option ... you have to use some kind of deployment & configuration mechanism.