The language isn’t perfect but I love working with it, these 8.1 and 8.2 improvements have really made it sweet.
My biggest gripe at the moment is the (very old) behavior of e.g. preg_match() and sort(). You’ve got a small handful of these common functions that operate on their input by reference/in place which is gross. A new version of these would be welcome.
PHP just happens to be good at getting stuff done fast, so it's found all over the place, and thus has a lot of eyeballs on it. The negativity is a byproduct of it's usefulness and staying power - the price of popularity, if you will.
I love PHP, especially with the new event loop based modules that let you do things asynchronously, much like Node or Go.
If you know how to use it well, PHP is awesome, and it's getting better with each release.
PHP opened the door to cheap web dynamic web hosting and in turn you had self-hosted applications like Wordpress. It was a few years later that languages like Java and C# became really attractive for back end work, you also had Ruby, Node, etc.
I wrote a lot of PHP in the early 2000s because that is were the work was, that’s what you could write open source code that people would use in, and it was really straightforward to build apps (like a social network for a secret society) without an ‘ops’ team watching your every move.
I don't like arguments like these because they're a tu quoque without even bothering to point out flaws in a different thing. It implicitly states that progress is impossible, that all languages will always be as bad, and nothing can ever improve because once a technology is widely-used, design flaws will magically appear. If you really believe that, write your next website backend in FORTRAN IV.
It was lazy argumentation when it was people saying Linux was just as buggy as Windows Me and it's lazy argumentation now.
Php is in a very similar situation, the difference is you can't escape javascript so we all to some extent keep up with its developments. People who leave php left it at a certain point and their understanding of its issues is frozen there. It's very predictable and boring honestly.
In fact php with composer and tooling is really good these days. Most people I've met (in person) who hate on php can't say why. They tend to equate php with wordpress.
I've picked up their projects and see many problems but I don't go blame the language they chose.
Yes it's a userland workaround and not a fix for the language, but it's thinking about these issues and a PHP extension (offering better performance) is being talked about.
The no-brainers to me are the missing array_some()/array_any() array_every()/array_all() and an array_search() that takes a predicate and iterable. I do these now in userland but an optimized native version would be nice.
What does that lib do that PHP doesn't?
Does it deterministically pass ALL tests in its own test suite yet? 100% of the time? This was the state just a few years ago, where a lot of tests were simply disabled because they were "flagging". <insert eyeroll emoji> (I'm not even going to touch the Boolean chart showing the different behaviors of single, double, and triple-equals on results. I know a lot of that has been fixed, at least by "convention".)
Nondeterminism is literally the worst trait of a computer language, because it leads to the worst kinds of bugs- the ones that are NOT a result of your lack of understanding of how the code is supposed to work at the PHP level. I've literally burned months away in my career in tracking down bugs like this (in Ruby and other languages), which ended up being framework or language bugs. There comes a point when you say "never again". Unfortunately, it comes too late in most people's careers to realize they've made a mistake, and switching to another language/community becomes too expensive/risky a proposition for them. (In my case I've been fortunate in that I was able to switch from .NET, to Ruby, to Elixir... each one of these was a difficult transition, both intellectually and socially (I really miss the Ruby community!), but in the end, completely justified in my case.)
Do you mean how you can have an optional out parameter to get more detail than what the return parameter gives for which group matched?
Personally i dont see anything wrong with that, but to each their own.
>sleep(int $seconds)
>returns zero on success.
>If the call was interrupted by a signal, sleep() returns a non-zero value. On Windows, this value will always be 192. On other platforms, the return value will be the number of seconds left to sleep.
I've used it for 2 years 2 years ago and I'm not at all interested in starting a project with it again
PHP is nothing if not amazingly well documented. This is more than I can say for a lot of languages I have worked in cough Ruby cough. I work pretty heavily in Go these days and even it’s docs leave me wanting in comparison sometimes.
Non-java devs think of java as Java 6 when in reality it has pretty significantly evolved in the last decade. I dare say that it's one of the most rapidly evolving mainstream languages on the market at this point.
We’re always looking btw.
Great! Keep using it! Ignore us. We (detractors) also had to use it and have since learned (hopefully several) other languages that (not looking at you JS) we like much better... :)
Major update, awesome. /s
As someone who manages a network of 250+ WordPress websites - these PHP updates are killing me! As soon as I'm done helping clients upgrade/fix their incompatible themes/plugins and custom code, a new version is out! Even with great tools, the process for about 10% of my network is a nightmare.
While I appreciate the work, it's not very satisfying and for many clients very frustrating to pay for something they know nothing about, just to "keep the lights on".
The plugin/theme developers usually develop with older versions of PHP in mind, lot's of plugins still work even with 5.x versions...
For my WP sites I just stick with "two major versions behind" workflow and I don't encounter many problems.
Am I doing it wrong?
Moving from 7.4 -> 8.2 will be just as much refactoring as moving from 7.4->8.0->8.1->8.2. Security support is in general three years [0] so everything 7.X is now unsupported. Considering the security cadence you can skip one version, but if you skip two you'll probably be out of security support before you migrate to a new version. My philosophy is if you're going to need to do the work to upgrade anyway, you might as well do smaller chunks more frequently and be able to take advantage of the language goodies that come out earlier.
The amount of the language that gets deprecated every year is PHP's fundamental flaw, at least in the last five years.
Eventually you have to upgrade. Do you want to go from 5.6 to 8.2 and possibly have to start over? Or do you want to go version by version, paying smaller amounts more frequently to stay current?
Also: WordPress + Themes + Plugins works best when you don't delay maintenance/upgrades. Everything needs to work in concert. You might be able to freeze your theme in time, but your plugins and the WP core will march on.
A lot of cPanel or similar hosts are also retiring old versions as they hit EOL [1][2][3][4][5] (those all support 7.4 still but most have indicated that will be dropped next year as well). This has made hosting transfers more and more difficult if you don't want to go through the process of upgrading.
The process of upgrading Wordpress sites isn't so bad (generally there's no work, honestly). But not all CMSs are that simple and it can get more laborious when you want to upgrade a Laravel or Symfony site, especially if you've skipped a few versions.
Of course, at the end of the day, it's up to the client to provide budget for these things and if they don't/can't, you just have to push back on their other requests until they do.
1: https://in.godaddy.com/help/retiring-old-php-versions-41164 2: https://www.bluehost.com/hosting/help/php-version-selection-... 3: https://help.dreamhost.com/hc/en-us/articles/215082337-What-... 4: https://wpengine.com/support/php-guide/ 5: https://getflywheel.com/wordpress-support/php-on-flywheel/#p...
7.4 just ended its security support so you might argue that you should be at least on 8.0 just in case a bug is found and not backported.
Truth is: it's not likely.
But in any case theres no need whatsoever to use the latest version and even less when you are using WordPress which is notoriously bad at keeping up with PHP releases.
[0]https://www.cloudways.com/blog/wordpress-performance-on-php-...
https://www.php.net/supported-versions.php
I know the web needs constant maintenance, but I wish it wasn't so much. PHP has been pretty good about not breaking changes, but I've noticed a few..
PHP is my goto. Its pretty great. It enabled a startup I was part of to get off the ground.
Shared webhosters (speaking for Germany) have started to disable support for PHP 7.x as there are no security patches anymore.
That made it necessary to upgrade lots of WordPress pages, especially older ones had some quirks in themes that broke with PHP 8.
I've updated around 25 sites for an old friend (she's more into the design/content part, not the dev part) and made good money with that. "Stupid" work nevertheless, would've preferred to do something better than run a PHP 8 linter and see where it breaks...
So there's some argument to be made to be in the 8.x series. It's probably not something you should be losing sleep over just yet, but at least have it on your roadmap to address in the coming months.
Also not a PHP problem but a WordPress problem. It's not a healthy eco-system.
I'd argue that's true for all of PHP. Sure it got better, but compared to other langugaes it is still a mess.
That said there are languages where very little backward incompatible changes are made. Java comes to mind.
Also: putting each client in a sandbox (VM, VPS, etc) can help you to keep some clients on the old versions, and/or do PHP interpreter migrations on your own timeline.
I do and appreciate the job security but I respect my clients (small biz owners) and it's just not satisfying and for the 10% that have issues, costly.
Java used to be like that, but the migration to the module system has been very rocky for me personally when revisiting older projects.
I even host a few installs on the latest 7.x version.
I don't understand where this update hysteria comes from. PHP 8.1 security support ends in Nov 2024.
How do you deal with Nginx/Apache updates given they release more frequently than PHP?
You can always host at a managed hosting provider who will take care of this for you.
I don't. We just finished upgrades from 7.4 to 8.0. PHP 8 was release November 26, 2020 - two years ago!
> How do you deal with Nginx/Apache updates given they release more frequently than PHP?
My managed host deals with that.
> You can always host at a managed hosting provider who will take care of this for you.
I have a "managed" host and none of them will make your code compatible. It requires a software engineer and lots of unglamorous work.
Can't speak for Nginx, but Apache updates very rarely screw with syntax, and those are always major releases. And for Apache, "syntax" just means config files.
PHP screws with syntax frequently, and often on point releases. And PHP is a programming language; syntax is the whole point of PHP.
Python 2 -> 3 change really was painful for Python community, but PHP does these almost fundamental breaking changes so often, that maybe people just get used to it? I haven't really followed Python past version 2, but I think they are less likely to ever do such amount of breaking changes.
There must be a lot of unmaintained PHP codebases that will break if PHP is updated by hosting provider etc. Someone must be pulling a lot of hairs because of this.
Edit: Those dogpiling there, I rest my case with josefresco's comment:
https://news.ycombinator.com/item?id=33907628
It's painful. Dropping dynamic properties? That will be a lot of fun. WordPress is probably biggest segment for PHP usage.
PHP also cares a great deal about backwards compatibility. There are long deprecation phases before anything gets removed.
The RFC system also helps a lot in ensuring that changes to the language are well thought out to and discussed beforehand. The is not much change just for change's sake. Churn is kept to a minimal while still allowing the language to evolve.
> There must be a lot of unmaintained PHP codebases that will break if PHP is updated by hosting provider etc. Someone must be pulling a lot of hairs because of this.
PHP upgrades are also good money for agencies. Got to earn that bread.
And to let out a dirty secret, for really hopeless projects there is the option to keep them on life-support by running them inside a docker container with an older PHP version. (Horrible but if that's what the customer wants, it's their risk.)
PHP 7 made a few big and necessary changes but they generally did not affect well-written code much. Python 3 broke a lot of things without good justifications, and without a way to make your code compatible with Python 2 at the same time.
There is benefit if you have the project under test and can run the build with different php versions thought. Best in parallel so you have current, next and future. It perhaps becomes the norm since the yearly release cycle but always was a requirement when supporting different php versions.
PHP has gone through a few changes.
PHP 3->4 was a moderately big change under the hood, and introduced a lot of new things, but most 3 'worked' under 4 (but was... awkward).
PHP 4->5 - a few 'big' things changed - XML processing changed - I had to use some shims to get some projects upgraded.
PHP 5->7 - my recollection, and that of most colleagues, is that this was pretty painless for most projects. I can't recall too many major breaking changes, but it was mostly just getting a doubling of speed without any substantive changes.
The PHP community has a couple decades of 'major version changes' to look at to learn from. I still can't say I agree with 100% of the decisions, but it's still progressing nicely.
They replaced the MySQL plugin in version 7. All MySQL code was broken. I don't know, but I'd guess that most PHP sites were using MySQL as their database (the 'M' in 'LAMP' stands for MySQL).
Even as someone who supported it. Perhaps there was internal built up resentment.
Whatever it was it showed in their communication.
Very occasionally I have to communicate on a topic I think could see backlash based on internal views. I make an effort to communicate it as neurally as possible.
My org currently prefers a saccharin approach when there is controversy I can't stand that, but I prefer it to over the like it or lump it bristling with rage approach Python took.
> There must be a lot of unmaintained PHP codebases that will break if PHP is updated by hosting provider etc.
Tons of them. If PHP really powers 50% of the internet, as they say, then maybe 25% of the internet is running an out-of-date PHP version. Then get into out of date Wordpress installs (can't risk breaking that plugin) and Magento 1 installs (out of support for half a decade, still in widespread use) and remember that they can't even update PHP without updating the Framework. In general, Laravel is sometimes better if the devs have been upgrading every LTS or so, that's once every two years. But if they miss an LTS, Laravel installs fall just as fall behind as any other framework. > Someone must be pulling a lot of hairs because of this.
No, nobody really cares. Sometimes I'm paid a lot of money to fix things, though, so I'm not bothered by the situation either. It seems that once a site is passed to the content managers, the only way to budget for upgrading the site is when there is a problem. Never mind that they might have some small internal dev team adding features all this time.I have a private (non-internet) web-app that's still on PHP6.5; I like the new PHP features, but upgrading private code to conform to PHP 7 and 8 looks a lot like make-work. I wish it shipped with good upgrade tools.
[Edit] @darkwater (below) is correct; I meant PHP 5.6. PHP6 was some kind of abortion - I can't remember the story.
I'm doing this quite often as I maintain some code-bases that have backward compat down to PHP 5.3 as the baseline. So if you're looking for forward compatibility of your PHP 5.6 codebase to 7.x and 8.x (incl. 8.2), its not so much of work.
If you need an upgrade tool, have different PHP versions at hand and load each file on the CLI and PHP will show you the deprecation warnings. It then depends a bit on the code (each()/next()/reset() family undergone some changes if not removals in 8? so you have to replace with some different syntax) but most of the rest is only deprecation warnings that can be overcome with #attributes "annotations" that are just comments prior php 8.
tooling could be better especially if you're running from low versions, thought. but using php on the cli directly brings you quite far and on speed already for most things in my personal experience. git, find and xargs are your friends.
IIRC, the initial development was in the mid 2000s but it was abandoned several years later because they couldn't get Unicode support working correctly. By the time it was abandoned there was already a lot of material referencing it like books and conference talks. So when the PHP team decided to do a new major version most of the planned PHP 6 features were already added to 5.3 and 5.4 so they thought it best to just skip 6 to avoid confusion.
PHP didn't learn from Python 3 BC fiasco, its governance makes such changes very difficult to be made.
I know this is contradictory to what some people love about PHP, but having a directory where everything is isolated and I just run npm start or my go binary or whatever is much easier to reason about for me, rather than also have to think about Apache's end.
That won't really solve having config files at different places though.
There is however a significant overhead to Docker. Building images takes time (and you will need to build your own, if you rely on any kind of PHP extension such as mbstring, etc) and just wrapping your head around everything is harder than people make it out to be.
That being said, I used to have my own set of bash scripts to setup local virtual hosts, databases, etc, and various strategies to keep configuration contained to single projects, but things always leaked out of the boxes I tried to put it in and in the end all those strategies failed.
So, my current estimate is that Docker doesn't save me much time, but it elevates the quality of the projects I'm working on. So overall I find it worth it to put in the effort to use Docker.
The codebases that you can create nowadays are light years away from what you would see 10 years ago. And the frameworks have improved alongside too.
For getting up and running, it saves time. For large projects, it adds leaky abstractions, overhead for each request, a need to upgrade another layer - with poor upgrade compatibility (in our anecdotal case), and very little gain. And it has it's own learning curve, which with modern PHP may be redundant.
Symfony looks better in that it is more of a library and less of a framework, though of course that has its own tradeoffs.
IMO, the weakest part of PHP is the db functions (both PDO and mysqli/postgres)
Edit: I'm talking about the php code being compiled / run by an external process which makes the whole thing staless.
It was a "working" design when people were dropping .php files in ftp folder on some hosting provider.
That it's stateless, and therefore often deployed with a module or FPM?
What "external" process are you talking about?
Also, I'll not pick any of the interpreted languages for that matter and would want Golang/Crystal/Nim to get single binary to be packaged.
But of course - this isn't necessarily something everyone would do.
There are no right or wrong answers here I suppose.
Web or something else?
I ask because I haven't heard many using Crystal/Nim for web.
That being said, one issue I've found is that while I can use VSCode for every other language, using PHP feels terrible if I'm not using a JetBrains IDE. I tried installing the PHP extension pack, but it was still leagues behind. Is there any guide someone can recommend for making PHP a first-class language in VSCode, or am I stuck in phpStorm?
It's possible that PHP's ubiquity and the core language's poor architecture/design (for decades now) are the source, not the ignorance of those complaining. PHP was the very first programming language I learned, in 1997. If anything, I mostly stopped disparaging it because I simply moved on in my career enough to be able to choose languages that aren't constantly fighting me.
I'm a consultant so I get asked about unfucking PHP codebases every few years, and I check in on the ecosystem and language. It's better but (unsurprisingly) still not great. Meanwhile, languages a decade+ younger avoided PHP's mistakes.
PHP supported versions - https://www.php.net/supported-versions.php
Edit for context: the small business that I work for takes on all kinds of random web work. It's not uncommon at all for us to be asked to rescue an application or website that's still running on PHP 5. For projects that we have initiated, by the time we migrate them all to PHP 8.2, it will be End of Life.
1. Compile PHP yourself (no)
2. Use an untrusted third party repo (probably not)
3. Upgrade OS to latest
4. (apparently) Use FreeBSD instead.
For all I know this could change. The current release schedule of PHP is greatly accelerated from what it was 5-10 years ago, and we're all still adjusting I think.
It's just like the Rust folks never miss any chance to bash C++, while C++'s market share keeps rising and after 16 years since Rust was created, it can not even make 1% of the market while C++ is 12%(excluding C which is 16%,again it keeps rising).
Rust's goal by the way should just replace Ada for specific areas, to take on C++ on a broader level it probably needs another few decades, if it can ever make it that is.
It's also not a contest? I'm not sure why people care about these numbers. PHP keeps getting bashed because it's a bad programming language full of footguns, then and now, regardless of whether or not other programming languages exist.
how is it 16 years when Rust 1.0 was released in 2015?
[1]: https://wiki.php.net/rfc/deprecate_dollar_brace_string_inter...
`words ${var} more words`
I thought we would start seeing more usage of this in PHP to make things more consistent.
I imagine it might crop up for people that also use Perl, since that would be more common there, like:
$foo="abc${var}def";
Kinda odd that Bash has had this syntax since forever, Perl as well, JavaScript went out of its way to add it as well, and now php is like: let's remove this syntax specifically but allow typo variants of it!
Oh well. Not like I was using it, that is, I use the bare "$foo" syntax and try not to make string interpolation too complicated with inline expressions or some such. Just, I could have seen the logic behind switching to the more universally supported syntax and deprecating something else rather than doing their one-off thing.
return self::CONSTANT; // Fatal error
however that is actually allowed, what is an fatal error is
return Foo::CONSTANT; // Fatal error
compare
https://3v4l.org/dIeOk#v8.2rc7
https://3v4l.org/11of1#v8.2rc7
Prohibit direct access through a trait name
As per how to select versions easily, the Symfony project provides a Symfony CLI and one of the features it provides is checking for a `.php-version` file in the current directory and selecting the correct php binary from the PATH accordingly.
I use that when I'm dealing with projects on different versions.
Well that's the thing: I don't know anyone who actively develops in Ruby, Python, Perl or Node that uses the OS-packaged runtimes. The system packages and the language-specific package managers live in different universes.
I've seen this situation blamed on both OS packagers or language ecosystems, but now I just think the goals between the two just are fundamentally at odds.
You _can_ use PHP from the command line but it's not the same kind of thing as Python or other languages where you need to be mindful of which version some shell script might assume is installed, etc..
That is for all but one version that is compiled from sources.
Note: I think PHP is way under appreciated.
They'd gather back my respect when they get rid of all the moronic behavior they have in the functions of their global namespace
* Like sleep that returns 192 on windows but not on linux when you interrupt it
* hash_hmac that if you pass array to $data, php will generate a Warning, return a NULL and continue, I'll let you imagine how bad this is in the context of hmacs when null gets typecast to 0 later on
* etc
Increased strictness in the types that can be passed to the built-in functions has been a general area of focus for the last several versions.
The thing is that PHP is (was) a good example of bad language design. It's original creator is (was) also known for its total disdain for "correct working software". The language and standard library even more show this quite clearly.
See reddit.com/r/lolphp for a community dedicated to bringing PHP's bad design pearls to the surface.
* function autoloading
* typedef
* templating hooks for escaping output and such
* better phpdoc, e.g define class without creating class, nested structures.
* inner class
* modules (instead of namespaces)2. Officially supported runtime that exposes system event loop to userland (yes, we have swoole and roadrunner)
EDIT: have you looked at ngx-php. It’s blazing fast and provides you that event loop.
It has some nice things but for everything in PHP, there other languages that do it a lot better. And I don't think CGI is a killer feature in 2022, it doesn't matter anymore than any other implementation detail, and causes more problems than it solves.
there is symphony/laravel as web frameworks, which by all accounts are modern and highly usable, but that in itself doesn't distinguish php given how many alternatives exist
The major niche has been carved long ago. Low cost code for budget conscience clients. PHP has long been the easiest on-ramp to webdev for many folks and some of the things out of it Wordpress specifically, can be utilized to cover a vast number of rather low complexity needs. If you consult with budget conscience clients, you likely find PHP indispensable. If you (or your employer) are building your own software product, you care more about DX and such and have chosen something else. In both scenarios, the end users of the product do not give a damn what it was built with.
I challenge you to find PHP deployed in production in any Amazon service