Live data from Hacker News

PHP in 2021

stitcher.io

141–150 of 309 posts

Re: PHP in 2021

#141

Before you call me a troll, know that I worked with PHP for two+ years maintaining both legacy codebases and writing new code with Laravel. My question is: why would anyone want to start something new with PHP in 2021? Is there anything that it does better than any other language/ecosystem? I feel like the community is full of (but not exclusively composed of—there are some gems like Caleb Porzio who write good stuff…

> My question is: why would anyone want to start something new with PHP in 2021? Is there anything that it does better than any other language/ecosystem? Well, on Twitter the other day, I asked, only partly tongue-in-cheek: > Even in 2021, any new server-side web app with even a vain hope of being installed by people who are tech savvy but not modern web nerds should probably still be written in PHP. True or false? T…

> I appreciate Laravel and Symfony, but PHP in 2021 has traded the feeling of being a cargo cult version of Perl for the feeling of being a cargo cult version of Java.

As a Symfony dev I agree. And the process to convert PHP into a Java-esqe Kotlin-esque language is continuing. Why not use a different language if you like it rather than change PHP?

> If I do write a new project in PHP, it's probably not going to be with any existing framework, because even the lightest one feels like endless mazes of "get a Request object from a RequestFactory by instantiating a dependency injection container and passing it to a RequestFactoryFactory".

I'll be interested to hear what you come up with. Two anecdotes:

1. I had to touch some PHP code I wrote many years ago based on the ColdFusion "Fusebox" architecture. It's missing some nice abstractions but unlike Symfony et al there was so little code I could understand what every line did within minutes. Parts of Symfony's internals are still magic to me (complicated by compiler passes).

2. I was asked to look at replacing a decade-old internal PHP app, the kind people look down on built using jQuery UI AJAX-powered datagrids and raw PHP. There were multiple problems like SQL injection but the app responded incredibly fast. I had to warn them that the replacement would feel slower unless they drastically increased the hosting, because a modern, engineered framework would've only finished booting up by the time this one was returning data.

Re: PHP in 2021

#142

Before you call me a troll, know that I worked with PHP for two+ years maintaining both legacy codebases and writing new code with Laravel. My question is: why would anyone want to start something new with PHP in 2021? Is there anything that it does better than any other language/ecosystem? I feel like the community is full of (but not exclusively composed of—there are some gems like Caleb Porzio who write good stuff…

I've worked with it for a little over a decade and I have to agree with you. It's a lot better than it used to be, it's just not very good. That said, the reason people use it is for it's popularity: It's easy to get into and almost everyone can write it badly. Much like javascript.

Re: PHP in 2021

#143

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…

You say

> medium quality framework with many flaws

Yet you only point out

> you can't autocomplete normally with an IDE

> You won't see methods that you may call

Firstly if there are "many flaws" list them because it seems you only don't like the developer experience with the autocomplete. I noticed no problem with browsing the Laravel API [0] with my short adventure with it.

> framework is 10-100 times slower than others

citation needed.

Also you didn't mention what you tried to use it for but remember software engineers are paid to pick the right tool for the job, Laravel is not the top pick for highly-concurrent idempotent microservice on Kubernetes, it's for monolithic app replacing that old WordPress installation without changing the tech stack

[0]: https://laravel.com/api/8.x/index.html

Re: PHP in 2021

#145
post #26
post #8

My beef with PHP is not so much the language itself, but the weird community that surrounds it. The FIG standard that forbids TAB for indentation (which is perfectly legal in PHP), the notion that classes should be either abstract or final, the micro-optimizations (thou must use single quotes, things like that). I don't think anyone can tell anyone how to write PHP, because nobody knows how to get it right (myself in…

PHP's chaotic developer community, as well as the "there are 1000 ways to do the same thing" philosophy that it inherited from Perl, is fertile ground for those who wish to say that they know better than others. This occurs in every level, from which quote character to use, all the way to how to arrange your namespaces. The PSR's also reflect this tendency. They're a mix of extremely useful standardization (e.g. PSR-…

Thank you so much, this is good advice and it's what I'm doing right now. Much like how a carpenter carefully picks the right tools to work with.

Writing code isn't an exact science and much like in probably any other profession, this requires us to twist and bend or even break the rules in order to create something beautiful. As a programmer, it's desirable to adhere to SOLID principles but without freedom of expression this is pretty much impossible.

A good mix of constraints and creativity can take years to develop and should probably keep developing over time as one exercises the art.

Re: PHP in 2021

#146
post #50
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...

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.

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

#147
post #43
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...

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 .

Consider that many Laravel installs will be done on CI servers.

Re: PHP in 2021

#148

Earlier quoted context omitted.

As a front-end developer I can agree with that. Many times when I've wanted to install something for my needs, like forum engine or something similar, I was looking only for an PHP option. Why? Because it really is a copy-paste process with typing credentials to your database into dedicated file. No need to know any language/framework-specific commands, and no need to be overwhelmed by missing dependencies. And in hu…

Discourse is a pretty complicated piece of software (relatively). They do: mailing list, discussion forum, long-form chat room, This isn't gonna be some static blog, it's feature heavy. It needs redis, it needs some real-time chat capabilities etc etc. Also the choice to use a framework (Rails in this instance) was sound since it's complicated. So when comparing deployments you need to compare it to the php equivalen…

So is facebook, and they wrote a lot of PHP for their first decade.

Re: PHP in 2021

#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 don't touch the code more than once every 5-10 years? - what is sufficiently resilient to mean that "mean time between rebuilds" is as long as possible?

Over all that time, what's lasted best are CGIs (Python/Perl) and PHP, running behind Apache.

I don't use PHP day-to-day, so changes in the language don't affect me much. But for keeping the history of the web alive, it is an unparalleled tool, and its proven commitment to longevity is why I still reach for it.

Separately: I think that longevity is a question we should ask ourselves more about the web. New ideas often come from experiencing old (even failed) ideas -- but if those old ideas just disappear, we lose some of our ability to progress.

Re: PHP in 2021

#150
post #62

I wish there was a nodejs equivalent to Laravel

This is very surprising to me honestly. Yeah, folks have pointed out some of the big players, but none of them have really risen above the competition. You would think NodeJS would have a clear cut dominant, monolithic web framework by now but there isn’t. Everyone seems to be happy to throw together hodge-podge Express apps.

I'm not sure whether it's due to the language or community, but it's the same with Go: there's a preference for libraries and very light frameworks over full-stack like Django/Rails/Laravel.
Post reply on HN