News for hackers. Stuff that matters.
Re:How PHP Opcache Works by BLO716 on Monday October 18, 2021 @11:17AM (#28906291)
Serious question, more out of curiosity on the state of PHP in 2021. Because of the advent of such things as Python (which I see a lot of comments in this thread about) - is it still relevant as a tool? I use it for minor projects internally to prop up a website on a Pi here and there, for ease of use - but curious what the state of the language is.

Anyone have stats on this?

Re:How PHP Opcache Works by mgkimsal on Monday October 18, 2021 @11:30AM (#28906469)
Are you asking "is PHP still relevant as a tool?". (the 'it' was slightly ambiguous to me.

PHP is absolutely relevant, I'd think, by many peoples' measurements. But... we're on a 'hacker' site and people love to dump on PHP. PHP powers a large portion of internet sites. One estimate from w3techs is ~80% of sites with a known server side language are PHP.

Yes, much is WordPress. If you estimate that half of that is Wordpress, that still would leave... ~35%-40% of sites using PHP. Maybe even that is too high. What if it's 30%? That's a large number, both in terms of percent and absolute numbers.

Yes, PHP is 'relevant'. The ecosystems (Symfony, Laravel, etc) are pragmatically iterating, evolving goods ideas from a wide spectrum of web platforms. The language itself is similarly pragmatic, adopting new features, deprecating legacy stuff, and moving forward. The language is roughly 3x faster than it was 10 years ago, while retaining a lot of backwards compatibility.

The language itself along with various frameworks offers a good combination of speed of development, flexibility and rigor. The 'shared nothing' default makes it easier to reason about for many problems. Need to write a small shell script? Easy in PHP. Need to scale up to large loads? PHP can do it. There will be scaling concerns in any large setup - a PHP platform will likely have similar problems that other language/stacks will encounter at similar load.

So again, yes, it's relevant. There will be some other response saying "no", and then ... we'd have to define what you mean by 'relevant'... :)

Popular? Growing? Evolving? Uptick in usage for many problem spaces? Easy to scale?

I'd say 'yes' to all of those.

Re:How PHP Opcache Works by javchz on Monday October 18, 2021 @07:42PM (#28913265)
A lot of people talk about serverless hosting like a new paradigm. But I will say the success of php was the huge amount of hosting providers where you send the files trough FTP, linked a domain and that's it, it's working.

No Linux terminal knowledge need it or worry about Nginx, SQL, or iptables configuration.

Yeah most of those cpanels hostings are bad for scale, but for a lot of new devs allowed them to deploy without having to be a sysadmin

Re:How PHP Opcache Works by smaps on Monday October 18, 2021 @09:33PM (#28913922)
Without those cpanel hosts I wouldn't be a web developer today. It was so easy for me to start messing around and teaching myself to code using them.
Re:How PHP Opcache Works by mkr-hn on Monday October 18, 2021 @01:55PM (#28908489)
On WordPress: it's important to remember it's a starting point for most of those uses. It's what people build entire platforms on when they don't want to/can't afford to start from scratch. People sometimes dismiss the number because "it's all WordPress," but that would be like dismissing Rails or Django. WP isn't exactly like Rails/Django, but it fills the same niche where you can pretty much assemble anything you can think of from pre-made components.
Re:How PHP Opcache Works by tmh88j on Monday October 18, 2021 @02:53PM (#28909813)
>WP isn't exactly like Rails/Django, but it fills the same niche where you can pretty much assemble anything you can think of from pre-made components.

Headless WP is becoming very popular too, and it seems to fill the same role. I've never used it, but I would imagine it takes just as much knowledge to build an SPA as any other backend framework like Laravel or Rails.

https://wpengine.com/headless-cms-research/

Re:How PHP Opcache Works by tored on Monday October 18, 2021 @03:10PM (#28910102)
Definitely. I write PHP at work, everything from 10 year plus legacy cruft to brand new projects, and it still works well.

I'm not a Python developer, but it is probably true that Python is a better designed language and has more bells and whistles as language, like decorators, operator overloading and modules. Python is also used in more domains than PHP.

But if you look past some of the weird design choices, bad reputation and the packaging as web only language, you will find a JIT-ed & typed dynamic language with good performance, FFI for easy C glue, good threading performance that is not suffering from a GIL like Python, a large & mature standard library, can be used everywhere from a small script to a large monolith, a true diamond in the rough.

Today I worked on a importing system that takes an HTTP stream to read a CSV file line by line to mangle it and rewrite it simultaneously to a FTP stream, never keeping the entire file in memory nor downloading it entirely to disk first, and by only using functions from the standard library.

I'm not saying you can't do this with Python, you probably can, or any other language, I just want to dismiss the idea that PHP is only suited for typical web tasks, PHP is a versatile tool that has every potential to expand outside of its traditional role.

Re:How PHP Opcache Works by mayli on Monday October 18, 2021 @05:01PM (#28911681)
Correct, even pypy provides the JIT, but it's missing in CPython. The performance is almost always the pain point of python, when compared to any web languages except ruby.
Re:How PHP Opcache Works by mszcz on Monday October 18, 2021 @04:53PM (#28911579)
What I miss the most in PHP is support for threading. Krakjoe did wonderful, unappreciated work with pthreads (the PHP extension). Sadly, that's no longer maintained.
Re:How PHP Opcache Works by ehnto on Monday October 18, 2021 @11:43AM (#28906676)
PHP has evolved leaps and bounds as a language, and as a community and ecosystem. It's still ubiquitous too. There seems to be an entirely theoretical delineation between "serious work" and PHP applications, but it doesn't exist in reality.

I still find it has one of the best developer experiences for web applications, out of all the tools I've had to learn through agency work.

Re:How PHP Opcache Works by Shish2k on Monday October 18, 2021 @11:32AM (#28906506)
It still has by far the lowest barrier to entry for basic deployments (pick any random cheapo shared web host; FTP your files to it; done) - that counts for a lot in the real world, and I’m sad that nobody else is even trying to compete :(
Re:How PHP Opcache Works by ehnto on Monday October 18, 2021 @11:46AM (#28906712)
I'm surprised too. Every other language ecosystem seems to be competing for the Most Enterprise Tooling Chain award. Can you deploy it without an AWS expert? Not enterprise enough!
Re:How PHP Opcache Works by slim on Monday October 18, 2021 @12:06PM (#28907018)
It seems to me that all that "serverless" stuff iscompetition
Re:How PHP Opcache Works by withinboredom on Monday October 18, 2021 @12:17PM (#28907165)
Yeah, I’d love to see some serverless php support since the language is made for that paradigm.
Re:How PHP Opcache Works by wwweston on Monday October 18, 2021 @12:53PM (#28907676)
It is... and that's potentially part of the problem. The value proposition at the low-demand end of serverless is less clear for PHP, since it's pretty much had that value (throw files on a cheap host and forget about the vanishingly small cost) for two decades.

Still compelling for people who see spiky to high traffic and are happy to have scale reduced to an accounting/budgeting problem, of course, and I'm pretty sure Laravel has something like this.

Re:How PHP Opcache Works by tomschlick on Monday October 18, 2021 @12:45PM (#28907580)
Thats exactly what Laravel Vapor does on top of AWS Lambda: https://vapor.laravel.com/
Re:How PHP Opcache Works by BafS on Monday October 18, 2021 @02:50PM (#28909767)
You should have a look to Bref (https://bref.sh/)
Re:How PHP Opcache Works by TrispusAttucks on Monday October 18, 2021 @01:07PM (#28907834)
It is supported on [1] AWS Lambda with a PHP Runtime.

[1] https://aws.amazon.com/blogs/compute/introducing-the-new-ser...

Re:How PHP Opcache Works by sroussey on Monday October 18, 2021 @12:31PM (#28907391)
I think AWS lambda supports php
Re:How PHP Opcache Works by withinboredom on Monday October 18, 2021 @12:36PM (#28907456)
There’s Bref for the Serverless framework but it only supports AWS and they have no desire to support any other frameworks.
Re:How PHP Opcache Works by rabuse on Monday October 18, 2021 @01:33PM (#28908139)
This may get me hung on HN for saying, but I honestly love working with PHP.
Re:How PHP Opcache Works by mszcz on Monday October 18, 2021 @04:58PM (#28911632)
Seconded. My brother got into frontend dev (JS mainly) so sometimes I probe him for what's being used. Each time I do this there's a new thing. And the JS tooling? my fucking god, how I despise it. The opaqueness of it all, the mountains of boilerplate code and files I need to download to do things "by the book". Whenever I dip my toes there I always long for the simplicity of my backend PHP setup and almost always try to ditch what's cool and new and do things as vanilla as possible.

Or maybe I'm just getting fucking old & grumpy ;)

Re:How PHP Opcache Works by mikojan on Monday October 18, 2021 @09:42PM (#28913963)
I've been writing personal frontend projects mostly in vanilla JS for over a year now. "Mostly vanilla JS", because I occasionally pull in a routing library (you'd probably do the same in PHP).

Modern JS (modules, web components, fetch, ...) is rather expressive and powerful, and you absolutely do not need to pull in a framework and twelve third-party hype technologies to get a small project up and running.

Re:How PHP Opcache Works by 1123581321 on Monday October 18, 2021 @12:10PM (#28907078)
The language still has plenty of footguns but most serious development is done through well-organized application frameworks and CMS starters. Performance is fine and can be parallelized as well as any application server language. There is a lot of documentation and community support for good proxy and server config, and plenty of hardened images or container configs, so the days of relying on pokey Apache on shared hosting are over for anyone who cares.
Re:How PHP Opcache Works by aklemm on Monday October 18, 2021 @11:40AM (#28906621)
It runs (most?) of the Web considering WordPress usage, but more interesting is the moderns ecosystem with excellent projects like Laravel.
Re:How PHP Opcache Works by greenshackle2 on Monday October 18, 2021 @12:44PM (#28907569)
Most of the web by traffic or number of websites?
Re:How PHP Opcache Works by jensensbutton on Monday October 18, 2021 @01:10PM (#28907861)
Largely both I'd imagine. Facebook, Slack, and Etsy all still run PHP (or Hack which is a PHP flavor) as far as I know. I'm sure there are a ton of other large web properties doing the same for their web tier.
Re:How PHP Opcache Works by kyriakos on Tuesday October 19, 2021 @01:10AM (#28915059)
All of the main adult industry properties run on php and that's a lot of traffic.
Re:How PHP Opcache Works by muglug on Monday October 18, 2021 @03:25PM (#28910326)
Hack is not a PHP flavour. It's a separate language that's inspired by PHP, with its own separate interpreter (HHVM).

Etsy still uses PHP, as does Vimeo and Wikimedia. A few other launched-in-early-oughts web properties rely heavily on it too (e.g. Flickr).

Re:How PHP Opcache Works by dec0dedab0de on Monday October 18, 2021 @01:03PM (#28907779)
As others have mentioned, WordPress is still huge. I believe Facebook is still mostly php, and I'm sure there are tons of sites started 2005-2010 that are still php.

PHP is easy to deploy, atleast from the start, but was difficult to use compared to python and ruby. It's deployment model also encouraged people to edit directly on the server, which lead to all kinds of problems. So it got a bad reputation.

I have heard that it has fixed many of it's inconsistencies, but many have already moved on. The ones still using it are either stuck, or happily quiet.

Re:How PHP Opcache Works by mkr-hn on Monday October 18, 2021 @04:23PM (#28911179)
I assume the addition of a local testing server to bring it up to speed with other languages improved things.
Re:How PHP Opcache Works by Darmody on Monday October 18, 2021 @01:51PM (#28908384)
Framework X Yoyo Revolt Swoole

Only to mention a few of the newest and hottest PHP tools. Then you have all the heavyweight, widely tested and used like Symfony, the Laravel ecosystem, Yii Framework, etc.

PHP has never been better and healthier.