Live data from Hacker News

PHP in 2021

stitcher.io

231–240 of 309 posts

Re: PHP in 2021

#231
post #5

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...

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  --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

#232
post #63

Earlier quoted context omitted.

Because getting a modern version of PHP, postgres, and redis up and running isn’t necessarily easy for your average beginner.

Does docker make it easier or harder though? I was testing out Apache Superset the other day and it recommends using Docker to do so. I am not strong in Docker - I prefer to run things from scratch so I know exactly what is going on under the hood - but thought I'd give it a go. I had so many problems getting it going. Part of it was the Superset instructions were slightly obsolete, but mostly it was this same proble…

> Does docker make it easier or harder though?

I happen to do web development and run a Docker course and I will confidently say it's a lot easier based on support questions and overall feedback that I've gotten over the years.

Because the alternative involves a ton of manual steps that every individual needs to take, for example with Python (and this applies to most languages / ecosystems with tiny changes):

- Which version of Python do I install? How do I install it on Windows 10? What about macOS? What's the instructions look like on my distro of Linux?

- How do I handle multiple versions of my programming language or install the language without the root user?

- I need to run Postgres, how do I install that on my OS?

- I need to run Redis, how do I install that on my OS?

- I need to run a specific version of Postgres / Redis for this project but a different version for another project, how to set this up?

- I need to use Webpack, how do I get Node installed and set all of that up

- How can I easily run all of my app's dependent services at once (web + worker + webpack + database + cache) without having to open multiple terminals or discover language specific tools with their own config files

- How can I use environment variables in my app that are loaded from a file?

- My app needs a library that requires a C dependency to be compiled to use it, how do I get that working on my OS?

Now imagine you're just getting into programming and want to build a web app with Flask, Django, Laravel, Rails, Phoenix or any other language / framework. You're going to need to do this for pretty much every tech stack and the learning curve for this stuff is really high when you're a beginner. There's so many unknown unknowns that lead to dead ends causing folks to get really frustrated and just say fuck it and never start.

But with Docker, you install Docker Desktop and technically you can treat it as a black box where everything is on a need to know basis. As long as you can find a reasonable base project to work off of getting started is as easy as installing Docker and running docker-compose up --build, and waiting 5-10 minutes. Now you can focus on learning the important thing (web development using the framework you've picked).

In most cases that works very well. Sure there's some installation related issues along the way but with tens of thousands of folks who have taken one of my courses using Docker, this a huge minority and it's usually something that's easily fixable (I offer support and deal with questions like this once in a while).

Re: PHP in 2021

#233

Earlier quoted context omitted.

> how the Discourse forum is now powered by a new six core 8 GB RAM server improving performance ... for 200 concurrent active users and 80k posts. I guess companies that use Discourse and have huge traffic can pay a bit more, nothing wrong with that.

> I guess companies that use Discourse and have huge traffic can pay a bit more, nothing wrong with that. The point being that said numbers aren't big traffic, they should be handled by a Raspi. But for the sake of argument: Discourse is a painless move upwards for big budget and/or big knowledge entities. Nothing wrong with that. On the other hand Discourse isn't a replacement for low cost, decentralized, easy to de…

So not sure I'm following, the php solution can handle huge traffic at a low cost with a conmparable feature set? How do they achieve that then? Taking a look at phpBB it looks like they are not using a framework (e.g https://github.com/phpbb/phpbb/blob/master/phpBB/posting.php). This is good for performance but pretty shitty for an OSS proeject, anyone looking to contribute here needs to start from scratch. Discourse happens to have 4x as many contributors. Also I can't imagine the feature set of the 2 projects is even remotely similar.

Re: PHP in 2021

#234
post #232
post #63

Earlier quoted context omitted.

Does docker make it easier or harder though? I was testing out Apache Superset the other day and it recommends using Docker to do so. I am not strong in Docker - I prefer to run things from scratch so I know exactly what is going on under the hood - but thought I'd give it a go. I had so many problems getting it going. Part of it was the Superset instructions were slightly obsolete, but mostly it was this same proble…

> Does docker make it easier or harder though? I happen to do web development and run a Docker course and I will confidently say it's a lot easier based on support questions and overall feedback that I've gotten over the years. Because the alternative involves a ton of manual steps that every individual needs to take, for example with Python (and this applies to most languages / ecosystems with tiny changes): - Which…

Docker on non-Linux OS's is just a VM. You could do the same by starting a linux VM w/ the system environment you're deploying on, and save the Docker overhead.

Re: PHP in 2021

#235
post #228

Earlier quoted context omitted.

> It's unrealistic to think that languages will stay static over 20 years Depends on the language really. JavaScript? Yeah, good luck even spinning up a year old project on NodeJS without any breakages. Slightly better situation in the browser but most likely you'll need to change something if you're using NPM. On the other hand, Clojure hasn't had a breaking change in their core API in almost 14 years now, since you…

> Depends on the language really. JavaScript? Yeah, good luck even spinning up a year old project on NodeJS without any breakages. Slightly better situation in the browser but most likely you'll need to change something if you're using NPM. Is that really true? I can't think of much in terms of older nodeJS stuff that would break on modern node (and with N, you can just install an older version of node).

Over long periods of time, and assuming I chose stable 3rd party libraries in the first place, I've found that breakages are down to (a) language changes, and (b) patched security holes. And that's where the risk of a majorly changed (or disappeared) library comes in, triggering a re-write. So it's not just a matter of sticking with the old stuff, unfortunately.

Re: PHP in 2021

#236
post #149

PHP has astounding longevity. In maintaining my personal websites (static pages, web toys, projects with my writing groups), I always ask myself: how will I keep this running in 20 years? It's unrealistic to think that languages will stay static over 20 years -- servers get rebuilt, old versions languages get deprecated, frameworks disappear. So the question becomes - will I know how to fix or rebuild this, even if I…

> It's unrealistic to think that languages will stay static over 20 years Depends on the language really. JavaScript? Yeah, good luck even spinning up a year old project on NodeJS without any breakages. Slightly better situation in the browser but most likely you'll need to change something if you're using NPM. On the other hand, Clojure hasn't had a breaking change in their core API in almost 14 years now, since you…

Interesting! I'm not from a Clojure world but that stability is great.

Re: PHP in 2021

#237
post #232

Earlier quoted context omitted.

> Does docker make it easier or harder though? I happen to do web development and run a Docker course and I will confidently say it's a lot easier based on support questions and overall feedback that I've gotten over the years. Because the alternative involves a ton of manual steps that every individual needs to take, for example with Python (and this applies to most languages / ecosystems with tiny changes): - Which…

Docker on non-Linux OS's is just a VM. You could do the same by starting a linux VM w/ the system environment you're deploying on, and save the Docker overhead.

> Docker on non-Linux OS's is just a VM. You could do the same by starting a linux VM w/ the system environment you're deploying on, and save the Docker overhead.

It's not close to the same user experience.

- If you roll a custom VM you need to first pick a hypervisor. Are you going to use vmware workstation, virtualbox or the native type-1 hypervisor on your OS such as hyper-v on Windows or hyperkit on Linux?

- Are you going to set up that VM using your hypervisor's UI or look into using something like Vagrant?

- What private network subnet are you going to choose when you set up your static IP to your VM?

- How will you get file sharing to work really well (complete with inotify support on Windows)?

- What about starting and stopping the VM for each project? What if you wanted to run a few projects at once with different exposed ports, how will you manage all of these VMs and the resources they've created?

- What if you're running native Linux and still want to isolate everything? Now go back to the first bullet point and add KVM, etc. into the mix

- Which Linux distro are you going to choose to run in the VM? If you're using Vagrant does your Vagrant box's OS support all of the guest features of your hypervisor?

- Now that you have your base Linux environment in a VM, how are you going to set up all of those bullet points I provided in my previous reply. It's back to the drawing board on having to do everything yourself but now on Linux.

A beginner developer is not going to have the same experience doing all of that instead of installing Docker Desktop and running docker-compose up --build. Docker is adding massive value from a convenience point of view and it gets much better once you go beyond your local dev environment too. Now you have a way to easily share your exact project set up process with another developer on any major OS and you can run your containers in the same way on a VPS if you deploy your app there too.

Re: PHP in 2021

#238

PHP has been in a pretty good place since 7, IMO. These are some great developments. I would say that Laravel is an extremely high quality framework (on par with and even in some ways better than Rails) that nobody should be ashamed to use. It's unfortunate that the stink of old PHP is so powerful and that salaries are still lagging so far behind.

> I would say that Laravel is an extremely high quality framework I strongly disagree. My experience with Laravel made me see it as a medium quality framework with many flaws. I'll point out to a few of them. The source code quality of the framework is not very high, and locally very poor. For instance, you can't autocomplete normally with an IDE unless you load extra declarations of the magic. Sometimes functions re…

> with an abuse of videos

Are you thinking Laracasts is the documentation or something? I don't think there is a single video in the Laravel docs.

> I have not worked with Laravel for more than 2 years, but at that time I could not find a public reference documentation

You can't have looked very far, because even now the docs go back to 4.2 (released 2014).

Re: PHP in 2021

#239

Earlier quoted context omitted.

> I guess companies that use Discourse and have huge traffic can pay a bit more, nothing wrong with that. The point being that said numbers aren't big traffic, they should be handled by a Raspi. But for the sake of argument: Discourse is a painless move upwards for big budget and/or big knowledge entities. Nothing wrong with that. On the other hand Discourse isn't a replacement for low cost, decentralized, easy to de…

So not sure I'm following, the php solution can handle huge traffic at a low cost with a conmparable feature set? How do they achieve that then? Taking a look at phpBB it looks like they are not using a framework (e.g https://github.com/phpbb/phpbb/blob/master/phpBB/posting.php ). This is good for performance but pretty shitty for an OSS proeject, anyone looking to contribute here needs to start from scratch. Discour…

> This is good for performance but pretty shitty for an OSS proeject

I don't see how. The repository seems to be quite active and has plenty of current pull requests.

Re: PHP in 2021

#240

Earlier quoted context omitted.

I am a fan of ASP.NET MVC. But honestly if you've used one MVC framework you've kind of used them all.

> if you've used one MVC framework you've kind of used them all Same goes for C-like languages like PHP or C#. Most of the features and syntax are the same across all in the family, so who really cares if it's Ruby, PHP or C#, they are more alike than they are different.

Well that's somewhat true too, though I think mandatory type declarations are a meaningful difference.
Post reply on HN