News for hackers. Stuff that matters.
Re:PHP in 2021 by chx on Thursday April 15, 2021 @08:19PM (#26827819)
In a post called "PHP in 2021" we really can't omit https://bref.sh/ -- it allows running PHP apps on AWS Lambda effortlessly. With all the serverless craze, it's a very important piece of the ecosystem. After writing PHP apps for two decades, I am absolutely stunned how easy it is.

Amazon blogged about it at https://aws.amazon.com/blogs/compute/the-serverless-lamp-sta...

Re:PHP in 2021 by ahofmann on Friday April 16, 2021 @08:09AM (#26832864)
So since only a few decades I can do this:

  1. create a shared hosting account for almost nothing (or literally nothing: https://www.000webhost.com/free-php-hosting)  
  2. write index.php  
  3. upload index.php  
  4. ???  
  5. profit!
But now, I can have the greatest and latest serverless multi-region, multi-something stuff with only these simple steps:

  1. create AWS Account
  2. follow these "simple" (nothing in AWS is simple) 4 steps to create AWS keys: https://bref.sh/docs/installation/aws-keys.html
  7. #npm install -g serverless
  8. #serverless config credentials --provider aws --key <key> --secret <secret>
  9. #composer require bref/bref
  10. #vendor/bin/bref init
  11. edit index.php
  12. #serverless deploy
  13. ???
  14. no profit, because your stuff went viral and your AWS bill is killing you
So at the end we have 14 steps to create something that potentially costs a lot and had an easier solution since about 1997. Awesome.
Re:PHP in 2021 by yboris on Thursday April 15, 2021 @10:40PM (#26828770)
I don't get it - the cheapest webhosts ($3/month) all let you run PHP - why would I need a cloud function when I have an always-on machine?

And if it's for something with high traffic, why would you want a cloud function anyway? I thought they are meant for "runs sporadically, so why have a machine that's always on?" setup.

Re:PHP in 2021 by chx on Thursday April 15, 2021 @11:21PM (#26829041)
I am using a lambda to answer a webhook. The lambda function writes into SQS and in turns, SQS calls a queue worker automatically.

Is this possible without AWS? Certainly. I was one of the two people who wrote the queue subsystem for Drupal more than a decade ago. And yet, AWS here does away with all the scalability concerns both up and down.

Re:PHP in 2021 by paulryanrogers on Thursday April 15, 2021 @11:01PM (#26828919)
When load varies you'll only pay while it's in use. Web-hosts without VMs or containers often promise a lot until you find their shadows limits. And those with VMs and containers can come out more expensive for some workloads.

The landscape is changing too. So if your work is stateless or relatively low bandwidth, and has variable load then it's probably worth trying FAAS.

Re:PHP in 2021 by mnapoli on Friday April 16, 2021 @04:23AM (#26831112)
With your webhost, you have to setup and maintain the server, including patching/updating it, setting up SSL, etc.

I used to do that for side projects, but I've had too many servers, and maintaining them was a pain.

For something with high traffic, Lambda provides the instant scalability. Imagine servers autoscaling, but instantly. And again, without having to setup or maintain that.

Re:PHP in 2021 by purerandomness on Friday April 16, 2021 @05:00AM (#26831381)
> With your webhost, you have to setup and maintain the server

You're confusing a root server or a VPS with a webhost aka "shared hosting", where the hosting service takes care of Let's Encrypt certificates, and scheduled downtime for patching.

Re:PHP in 2021 by kijin on Thursday April 15, 2021 @09:48PM (#26828440)
For what it's worth, PHP has always been kinda "serverless". You just point the PHP interpreter at a file, and it runs the script contained in the file!
Re:PHP in 2021 by jfrunyon on Friday April 16, 2021 @01:29AM (#26829872)
That's how literally anything which is "executable" works. You just point the interpreter (kernel, ld-linux, php, python, ...) at a file, and it runs the file.
Re:PHP in 2021 by kijin on Friday April 16, 2021 @10:20AM (#26834210)
Exactly, and PHP brings this simple intuitive behavior to the web. You just point your browser at a .php file, and the server runs the file for you.
Re:PHP in 2021 by jfrunyon on Wednesday April 21, 2021 @02:25AM (#26886025)
Sure, once you've set up the web server, and PHP itself, and installed (usually through a not-easily-wget'able link) the program you want, and configured it, and set up its permissions properly...
Re:PHP in 2021 by slt2021 on Thursday April 15, 2021 @11:10PM (#26828973)
+1. PHP can easily host 1000 applications on a single node, while java people would struggle hosting 1000 docker contained spring boot monsters
Re:PHP in 2021 by muglug on Thursday April 15, 2021 @10:21PM (#26828643)
FWIW Bref is cool, but it's AWS-only and still has a couple of orders of magnitude fewer daily installations than Laravel: https://packagist.org/packages/bref/bref/stats vs https://packagist.org/packages/laravel/framework/stats.
Re:PHP in 2021 by mtnGoat on Friday April 16, 2021 @12:27AM (#26829450)
Not sure they are comparable as they serve very different needs.
Re:PHP in 2021 by porker on Friday April 16, 2021 @04:26AM (#26831143)
Consider that many Laravel installs will be done on CI servers.
Re:PHP in 2021 by muglug on Friday April 16, 2021 @07:59AM (#26832788)
I guarantee that a larger % of the bref installs will be done on CI servers (bref is newer, and users of it are generally more advanced)