What people who don't work on content sites don't realize is that from 10 best CMSes like 7 are written in PHP. And i don't even mean Wordpress. It's stuff like Craft, Kirby, Twill, October, Bolt, Statamic, Bookstack, Dokuwiki, Mediawiki… there few OK ones in Javascript but they lack features and maturity.
That's why it's so popular in those circles. If you want really solid selfhosted platform for publishing/ecommerce you can't avoid it.
For SPA web apps or anything realtime… sure there are probably better choices. But many agencies transition to making small apps with devs already knowing PHP then it's not bad choice.