Live data from Hacker News

PHP in 2021

stitcher.io

21–30 of 309 posts

Re: PHP in 2021

#21
post #19

I know PHP is really great (and always has been). But sh*t, there is soooo much bad, no, really really bad PHP code that lives out there. Isn't it?

Sure, but you can say as bad or worse about almost all code in the wild. Almost everything is garbage.

Sturgeon's Law applies.

Re: PHP in 2021

#22
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…

If you look at a language like Go, it's rare to find a project not using the standard gofmt. PSR-12 states that "the benefit of this guide is not in the rules themselves but the sharing of those rules". The guidelines to use single quotes and tabs vs spaces exist for the sake of consistency, to remove that subjective argument from the conversation.

Re: PHP in 2021

#23
post #11

It's nice to see PHP adding useful things like enums and async (green threads). My foray into Web development started with Perl, but quickly segued into PHP with how much simpler it felt. The ability to hop into vim on your server (or use CPanel back in the day) and edit your site live was exciting back then – but now that very thought makes me shudder with what could go wrong, haha. While I've moved onto JVM languag…

What do they want async for? PHP's purpose is to run once to generate one HTTP response - they'd already forgotten this by inventing frameworks, but adding async seems to especially have forgotten this.

PHP already had curl_multi_perform which is very useful for running child tasks, but I'm not sure you need much more than that.

Re: PHP in 2021

#24
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…

It's just a linting standard. You're free to use it or not and some linters support the entire specification as-is but with tabs instead.

Re: PHP in 2021

#25

I know PHP is really great (and always has been). But sh*t, there is soooo much bad, no, really really bad PHP code that lives out there. Isn't it?

Yeah, also some incredible literature and worthless spam. Practically infinite expression will inevitably lead to poor results in one corner or another.

Re: PHP in 2021

#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-4) and hardcode nitpicking about whitespace (e.g. PSR-12). Take what you need, focus on maintainability and interoperability, and ignore the noise.

Re: PHP in 2021

#27
post #11

It's nice to see PHP adding useful things like enums and async (green threads). My foray into Web development started with Perl, but quickly segued into PHP with how much simpler it felt. The ability to hop into vim on your server (or use CPanel back in the day) and edit your site live was exciting back then – but now that very thought makes me shudder with what could go wrong, haha. While I've moved onto JVM languag…

What do they want async for? PHP's purpose is to run once to generate one HTTP response - they'd already forgotten this by inventing frameworks, but adding async seems to especially have forgotten this. PHP already had curl_multi_perform which is very useful for running child tasks, but I'm not sure you need much more than that.

The usual asynchronous stuff like fetching data from two APIs to then prepare the HTML response to the user. Today, it's sequential, which is fine for DB calls to localhost, but less fine with API calls.

Re: PHP in 2021

#28
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…

FIG standards are explicitly interoperability standards. They make it easy for anyone to jump into a new company or open source project with minimal friction and minimal bikeshedding.

If you or your team don't care about that and want to do something different, there's nothing stopping you. Even the Symfony team, who contributed to these standards and largely follow them, have gone their own way when they thought it was worth the trade-off.

Re: PHP in 2021

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

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

#30

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 (on par with and even in some ways better than Rails) that nobody should be ashamed to use.

Never heard of Laravel. Decided to take a look. First thing the intro documentation says to do is install something called 'Docker Desktop'. I'm good, thanks.

Why do I need Docker to play around with a web framework?

Post reply on HN