[HN Gopher] An Internet of PHP
       ___________________________________________________________________
        
       An Internet of PHP
        
       Author : edent
       Score  : 265 points
       Date   : 2023-09-07 07:23 UTC (2 days ago)
        
 (HTM) web link (timotijhof.net)
 (TXT) w3m dump (timotijhof.net)
        
       | okeuro49 wrote:
       | I like PHP, because it has a familiar C-like syntax and great
       | tooling, like composer, and frameworks, like Symfony. The
       | language has warts, but it's improving.
       | 
       | I think its strength is its architecture, namely shared-nothing
       | state and concurrency at the web-request level. [1]
       | 
       | [1] https://slack.engineering/taking-php-seriously/
        
         | jtjoadfs223 wrote:
         | HHVM is evidence of the weakness of PHP and is a bandaid hack,
         | but the article spins this as justification for PHP.
         | 
         | What would you do if HHVM didn't even exist?
         | 
         | Admittedly PHP has had recent performance gains, but by no
         | means would it ever be a first choice in any backend service
         | architecture.
        
           | okeuro49 wrote:
           | > What would you do if HHVM didn't even exist?
           | 
           | If you're referring to the Slack article, it is a bit out of
           | date.
           | 
           | PHP has since added stronger typing and better performance. I
           | don't think using HHVM is very popular.
        
       | iambateman wrote:
       | For those of you who are proponents of other web ecosystems, I'm
       | curious what benefits you enjoy? What framework or language do
       | you use and what makes it great?
       | 
       | I use PHP everyday but we definitely have a lot to learn from
       | others.
        
         | JodieBenitez wrote:
         | Starting from 1997, over the years I completely replaced PHP
         | with Python. Apart from the language itself, which I like a lot
         | for many reasons, some benefits that come to my mind:
         | - Better libraries and frameworks overall         - Better
         | programmers overall, so more competent colleagues         -
         | Relevant in many fields outside web development         -
         | Allows to learn and use various paradigms, like
         | async/multithread/multiproc...
         | 
         | I do keep track of PHP improvements. In fact, I keep a small
         | personal toy framework as a way to test its new features. Some
         | of these were very much welcomed, like safe mode + runtime
         | typing. But some of these were just catch-ups and none of these
         | are compelling enough so that I would want to start a new
         | project in PHP.
         | 
         | Other ecosystem I'm interested in is Go, for other reasons.
        
         | JonathanBeuys wrote:
         | I expect Python to be more stable over the coming decades than
         | PHP.
         | 
         | PHP had a lot of breaking changes in the last version. Changes
         | which got pushed through despite being quite controversial. I
         | fear that this trend will continue.
         | 
         | Python had breaking changes in version 3, but at least those
         | made the language better. PHP's recent changes were unnecessary
         | and counterproductive.
        
       | anonymous344 wrote:
       | php runs securely in 5minutes in any web server 3-10$/month.
       | 
       | Every other tech, it's complicated servers or complicated
       | billing, not to mention depencies and build tools.
       | 
       | thats why php
        
         | quickthrower2 wrote:
         | Not sure why it is downvoted as this is true. That said it is
         | more to do with shared hosts culture choosing PHP than PHP
         | itself. (They tend to support Ruby and Node but not as well)
        
           | nasretdinov wrote:
           | PHP is also pretty easy to support for shared hosting, as
           | what they essentially need is just an Apache module (+ nginx
           | probably), some clever filesystem permissions and they're
           | done. For node, Python, etc, you actually need to keep the
           | application servers running, which has to stay running even
           | when they're completely idle. So I think PHP is a natural
           | choice for shared hosting for those reasons too.
        
             | xigoi wrote:
             | > For node, Python, etc, you actually need to keep the
             | application servers running
             | 
             | Not with CGI.
        
               | nasretdinov wrote:
               | You're technically right, however I imagine performance
               | would be really poor, especially for Node. PHP has
               | transparent opcache support and it's generally fairly
               | efficient when run as Apache module, so it's usually
               | preferred. You can of run PHP as CGI as well, however
               | it's much slower.
        
             | oaiey wrote:
             | This is exactly to the reason why PHP and before perl are
             | successful in this space.
             | 
             | When you extrapolate that to modern tech, you could create
             | a shared hoster with a configured reverse proxy and per
             | customer docker images.
             | 
             | But that is so much expensive to build, operate and bill
             | than an apache. And looks very close to AWS and friends.
        
             | azlev wrote:
             | I worked 10+ years in a web hosting company. PHP was chosen
             | not because it was easy, it's because most people just use
             | a CMS or something in PHP.
             | 
             | Keep a shared host secure, PHP or something else was not an
             | easy task, most people installed unsecure versions or
             | misconfigure something.
             | 
             | Also it was a pain to support PHP versions after EOL (yes,
             | money), and multiple versions .
        
         | timeon wrote:
         | I wish cheap server hostings allowed loading php modules or at
         | least had FFI module. Imagine thin php API-layer with rust-or-
         | whatever-module under the hood. Easy deploying toys without
         | need of VPS.
        
         | 1023bytes wrote:
         | Well it's not exactly secure by default. I was deploying an app
         | to a new server and some bot grabbed my .env file before I
         | finished the Apache config. Ultimately it's my own stupidity,
         | but you don't have to worry about that with most other
         | languages
        
           | zmxz wrote:
           | So it wasn't the language, it was you? But it was the
           | language?
        
             | pwdisswordfishc wrote:
             | Just like in C, where every buffer overflow bug is the
             | programmer's fault.
        
           | phendrenad2 wrote:
           | If you apply the same level of thoughtlessness to any other
           | framework, I assure you bots will grab your config also.
        
           | gumballindie wrote:
           | Yes but that's a framework specific issue. And usually your
           | documentroot would point to a directory below that which
           | holds .env. Oh the memories of apache and php.
        
             | Nextgrid wrote:
             | The mere concept of a "document root" is a problem though
             | and a major footgun if you don't know what you're doing.
             | 
             | Every other language acts as its own web server which
             | wouldn't even be capable of serving files even if you
             | tried; the only thing it does is respond to web routes
             | defined by the application.
             | 
             | This eliminates a whole chunk of security issues, from the
             | one described above to malicious file uploads (PHP is
             | probably the only language where a malicious file upload
             | leads to RCE by default - other languages could happily
             | accept and serve the malicious file back but wouldn't
             | _execute_ it).
        
               | gumballindie wrote:
               | > The mere concept of a "document root" is a problem
               | though and a major footgun if you don't know what you're
               | doing.
               | 
               | A non issue though after 2-3 days of working with this
               | approach. All modern PHP frameworks have a so called
               | front controller (an index.php file) that loads what it
               | requires from ../ after, ideally, properly validating the
               | request to avoid issues.
        
               | pavel_lishin wrote:
               | > _A non issue though after 2-3 days of working with this
               | approach._
               | 
               | Tell that to all the people with bleeding feet.
        
             | tacker2000 wrote:
             | Your comment makes no sense. How is that framework or PHP
             | specific? Its simply a misconfiguration the server.
        
               | gumballindie wrote:
               | Some frameworks in the old days of PHP relied on
               | .htaccess files to restrict access to unwanted files.
               | Properly implemented frameworks would load everything
               | from a directory above the documentroot to avoid these
               | issues.
        
               | tacker2000 wrote:
               | .htaccess is a config file type used by the Apache web
               | server.
               | 
               | The server software reads the config file and then
               | decides if the folder can be accessed externally or not.
               | 
               | It has nothing to do with PHP what framework or any other
               | language you are running.
        
           | [deleted]
        
           | shakesbeard wrote:
           | You shouldn't deploy .env files to production. You should set
           | the actual environment variables on production. .env files
           | are intended for convenience on non-prod systems.
        
             | 101011 wrote:
             | Agreed, but server frameworks shouldn't easily enable a
             | foot gun that allows bots to have disk access to your host.
             | Instead, only explicitly defined routes or resource files
             | should be available.
             | 
             | If I had to guess, this person committed their .env file in
             | some repo and pushed that up, and that become available
             | because the server was misconfigured.
             | 
             | For other servers (such as, say, Jetty), config files like
             | that won't get exposed like that unless you're very
             | obviously placing your config files in a public resource
             | folder.
        
         | todotask wrote:
         | Doesn't cPanel supported several langauge including NodeJS
         | runtime? I think most projects use composer or PHP packages.
         | 
         | Thanks to cPanel (written in Perl) this make life easier for
         | developers to set up websites and skipped the ceremony but why
         | is cPanel written in Perl instead of PHP?
         | 
         | But Go language has it own security implementations which are
         | more secure and easier to deploy as a static binary. I did
         | tried to write entire Go app using only built-in or some dev
         | use Chi for routing. I didn't have to install Go runtime on VPS
         | that you need for PHP.
         | 
         | Go built-in HTML template is quite secure, rare seen some fix
         | to html/template make it easier to deploy new app, but our
         | website has evolved with Astro web framework that require
         | NodeJS since none of the server side language can solve client-
         | side issues.
        
         | prfssnl wrote:
         | True. I setup a woocommerce site for someone 3 years ago, still
         | makes around $1000 a month (pretty good for a small biz in
         | India) and I just helped them downgrade from a $10 digitalocean
         | VPS to a $3 cpanel hosting.
        
       | synergy20 wrote:
       | PHP was not great in the early days, same goes for Javascript,
       | but they made web we use today, I'm not going to use today's
       | standard on yesterday's realities. Both have moved on and are
       | much better off now.
       | 
       | Comparing to PHP, modern frontend is the true mess still though,
       | there was never a simple to use SPA frontend in existence,
       | they're all complicated, over-engineered and changing too fast to
       | me, and now they are even adding what PHP was good at(SSR),
       | frontend is the problem and getting even worse to me. The
       | backend, be it PHP-laravel, Ruby-rails or python-django, even
       | node-express are an already solved problem, the frontend
       | framework folks adding SSR into frontend frameworks are simply
       | insane to me.
       | 
       | NOTE I'm not against SSR, what I dislike is that they add SSR
       | directly into an already over-complicated SPA framework, which
       | will kill itself under its own weight soon.
        
       | kristaps wrote:
       | 77% of top 10M sites - sounds like reeling in the long tail for
       | effect, has to be way lower for the top 1K sites.
        
       | Andrew018 wrote:
       | [flagged]
        
       | innocenat wrote:
       | One thing I absolutely love about PHP is the mod_intl which is
       | almost always enabled everywhere. It provides ICU Transliterator
       | and BreakIterator which is godsand to handle user-create content
       | that's in Asian, Complex Script, etc.
       | 
       | Last I check a few year ago Java is the only other platform with
       | as good ICU integration, and nodejs has BreakIterator but not
       | Transliterator. Other platform require complex setup to install
       | ICU as a third party library.
        
       | phendrenad2 wrote:
       | Related: I recently discovered the "fanlisting scene". In the
       | early 2000s, some people started a trend of creating fan sites
       | (a.k.a. shrines) for characters in TV shows, anime, games, etc.
       | These sites ran on simple PHP codebases, such as Enthusiast,
       | PHPFanBase, and BellaBuffs. Someone interviewed one of the
       | developers here: https://hey.georgie.nu/hg-jem/ (For some reason
       | fanlistings tended to use .nu domains, because it was cool I
       | guess).
       | 
       | Most of these fanlistings (and also the massive number of forums
       | running on vbulletin and phpbb in the early 2000s) were created
       | not by software developers, but people who had a passion. It was
       | a road that a lot of people, especially girls, took to get into
       | software development. I think that gender parity in software
       | development might have hit a record high during that time.
        
       | gjvc wrote:
       | As soon as WASM is able to draw to the canvas, we can stop using
       | the DOM for anything and everything and pick up where we left off
       | with GUI development in the 1990s.
        
         | phendrenad2 wrote:
         | Dealing with text would still be a huge problem. Drawing text
         | on canvas and making it selectable is still a hard problem, you
         | have to think about all the intricacies of text (character
         | widths, spacing, RTL, etc)
        
       | ctas wrote:
       | > Slack uses PHP for most of its server-side application logic
       | [...].
       | 
       | Slack migrated to Hacklang in 2016 [1].
       | 
       | [1] https://slack.engineering/hakana-taking-hack-seriously/ "We
       | started migrating to a different language called Hack in 2016."
        
         | Matl wrote:
         | Isn't Hack basically compiled PHP so that it is faster for FB's
         | use case? I understand it's not technically PHP, but I imagine
         | it is effectively still PHP, or is it more like what C++ is to
         | C?
         | 
         | I understand PHP is fast adding any actual language features
         | that Hack has over it?
        
           | phyrex wrote:
           | At one point it was, but since then it's become it's own
           | language with a completely new (JIT-based) implementation
        
       | muglug wrote:
       | I'm quoted a bunch in this, which I appreciate, but there's one
       | mistake here -- Slack no longer uses PHP, having migrated its
       | codebase to Hack.
       | 
       | Also listing language usage by what's returned in server headers
       | undercounts languages used on some of the biggest, most popular
       | internet properties.
       | 
       | Sites like Amazon, TikTok and YouTube/Google consume a lot of our
       | total attention, but they tend not to report their backend server
       | languages in response headers.
       | 
       | If you shift from raw numbers to where people actually spend
       | their time, I doubt PHP would be at the top.
        
         | tacker2000 wrote:
         | Hack is a "dialect" of PHP created by Meta to be more
         | performant and have types, among other features. So its not
         | like they shifted their codebase to an entirely new language.
        
       | nunodonato wrote:
       | "PHP is dead" is dead. The amount of people praising PHP these
       | days is quite high and increasing. Of course I may also be in a
       | bubble (of php devs), but I have seen a constant increase from
       | JS-people starting to look (and in some cases, convert to) php.
       | Also, many new youtube videos highlighting the new stuff in the
       | language, how modern it is, etc.
       | 
       | Honestly, anyone that _blindly_ criticizes or dismisses php these
       | days, is a big red-flag for me.
        
         | nikanj wrote:
         | It's like meeting someone in 2023 who hates Micro$oft WinBLOWZ.
         | Have they been stuck in stasis for 20 years? What other values
         | from the 9/11 era do they hang on to?
        
           | dash2 wrote:
           | This reminds me of the sysadmin at a Greek university I once
           | worked in back in 2009 or so. He had installed Linux at every
           | one of the computer labs' computers. He'd changed the startup
           | software to describe Windows as Windows UnProfessional. The
           | default was Linux, and it would boot within 3 seconds unless
           | you quickly changed it. Under Linux he'd included all the
           | Gnome 2 window manager flash, including spinning cubes and
           | windows that went up in flames when you closed them.... He
           | convinced my friend to install Linux on her laptop. Good
           | times.
        
             | quickthrower2 wrote:
             | A budding RMS!
        
             | oaiey wrote:
             | I like the fun spirit of it. We do not have these people
             | anymore.
        
           | MrVandemar wrote:
           | Yeah? Last time I installed Microsoft Windows -- I was
           | genuinely giving it a chance -- it asked me during the
           | install if I wanted to see ads.
           | 
           | Well, that's like asking me if I wanted a recreational root-
           | canal, so I answered "no".
           | 
           | Boot into the OS, and the task-menu-bar-thing is spinning
           | with X-box ads and all sorts of other crap.
           | 
           | I dispensed with that shit immediately, and gained a nice
           | little extra disk-space for my /home dir.
        
           | archerx wrote:
           | Ironically since windows 11, after being pro windows since
           | version 3.11 I have pretty much turned disdainful to
           | Micro$hit WangBLOWz. What a time to be alive.
        
           | JuanPosadas wrote:
           | lolwut windows is _worse_ now than it was 20 years ago.
        
           | dagw wrote:
           | _It's like meeting someone in 2023 who hates Micro$oft
           | WinBLOWZ._
           | 
           | As someone who was on the whole pretty pro Microsoft for the
           | past several years, 2022-2023 was when I started 'hating'
           | Microsoft again. Both today me and year 2000 me would agree
           | that 2020 me was completely wrong about giving Microsoft the
           | benefit of the doubt.
        
           | indymike wrote:
           | Windows was getting better until MS started preventing users
           | from deleting files, even if they are the owner of the
           | computer. Yes, it is a foot gun, but it also makes fixing
           | problems difficult and sometimes even impossible. Windows 11
           | seemed pretty nice until my son had a problem installing a
           | game and one of those "untouchable files" was the wrong
           | version, so every 10 minutes or so you'd get an error
           | message. We fixed it by re-imaging it with Debian and Steam.
           | 
           | > What other values from the 9/11 era do they hang on to?
           | 
           | I'm still into taking care of my family, being honest with
           | people, being nice to people, even if they are not nice to
           | me, and I still like a good single malt whisky.
        
           | croes wrote:
           | You mean like hating MS for putting ads in the OS?
           | 
           | MS didn't change, they still exploit as much as they can.
           | 
           | And they try to force people people into the cloud unable to
           | secure their own software stack.
           | 
           | MS didn't get better just because Google got worse.
        
             | nunodonato wrote:
             | Don't forget that now Microsoft  Linux
        
               | Nextgrid wrote:
               | I'd much prefer the previous one that hates Linux but
               | actually gives me a usable OS & tooling without ads or
               | other user-hostility.
        
               | rvnx wrote:
               | Windows 7 was great.
        
               | ekianjo wrote:
               | [flagged]
        
               | oaiey wrote:
               | More like a husband talking bad about his wife for years
               | and as soon as he realized that she earns craploads of
               | money becomes a supporting and loving Partner.
        
           | popcalc wrote:
           | This might have been among the worst examples you could have
           | used, considering current affairs.
        
           | ekianjo wrote:
           | Oh instead do people believe the obvious BS that Microsoft
           | loves Linux and FOSS and has become an ethical company?
        
         | jbverschoor wrote:
         | Well the problem is that "the internet" (google, stackoverflow)
         | does not (by default) filter out any old/obsolete information.
         | 
         | People googling for solutions will get 30+ year old "advise" on
         | how to do certain things / use certain libraries etc.
         | 
         | Especially StackOverflow should be incorporating a major
         | version number for which the question is valid.
         | 
         | So yes, "PHP is still dead" as long as you get the same old
         | advise.
        
           | nunodonato wrote:
           | that's very true. But it is true for PHP as it is for any
           | other language or tech that is at least a decade old.
           | Interesting fact: chatgpt can recognize old stuff and give
           | better recommendations
        
             | jbverschoor wrote:
             | Still, somehow it's more true for php.. maybe because other
             | languages invest more in migrating to newer standards.
             | Maybe because so many projects are self-hosted by non-
             | programmers, in which case it makes sense to be
             | conservative
        
           | 8organicbits wrote:
           | StackOverflow has been trying to address that problem. I've
           | recently seen them show a newer answer on top of the
           | "accepted" answer even though it had fewer votes. This helps
           | the answer evolve over time.
           | 
           | https://meta.stackoverflow.com/questions/405302/introducing-.
           | ..
        
             | jbverschoor wrote:
             | But that's not the problem. The problem is that the
             | questions are old.
             | 
             | It's better to have the same question in a new era. The
             | version info should be in the question. The question has
             | either been answered or not, but it's not relevant anymore
             | for the original poster.
             | 
             | Only if it really is, you could add a new major version to
             | it to indicate compatibility
        
               | 8organicbits wrote:
               | I'm not sure I see the distinction. I've needed help
               | doing "X", I googled "how to do X", and found ancient
               | stackoverflow questions. The page has recent answers
               | ranked the highest saying things like: "in recent years
               | you should use the Y feature to do X". I haven't seen
               | anyone get upset that the Y feature didn't exist when the
               | question was posted.
               | 
               | Questions are often timeless. The answers change and SO
               | shows them all with their timestamps ordered by its best
               | guess at which will help you, the reader, not the
               | original poster.
        
       | brendamn wrote:
       | From W3Tech;
       | 
       | > PHP is used by 77% of all the websites whose server-side
       | programming language we know.
       | 
       | I had a quick look at the methodology section, but it's not clear
       | to me how accurate this data is. Determining whether a site uses
       | PHP can be relatively straightforward (especially with default
       | extensions / if Wordpress is used / etc), but if a site
       | (potentially using a different language) is behind a reverse
       | proxy/uses an API/etc then it is less clear. Does anyone know
       | whether PHP is over-represented in the results because it's easy
       | to identify?
       | 
       | No doubt PHP is still huge, but 77% seems almost too huge. There
       | is also a very good chance that PHP is actually that big and I'm
       | just in a different crowd.
        
         | madduci wrote:
         | A lot of news outlets, e-learning and e-commerce websites are
         | running on CMS/Frameworks made with PHP. Just to mention a few
         | of them:
         | 
         | - WordPress - Joomla! - Magento - Moodle - Zend Framework/Cart
         | - Laravel - Symfony - Open E-commerce
         | 
         | If you count all the websites using one of the above items, you
         | will come up with a huge list of websites.
         | 
         | And way too many Academic sites are running on PHP.
         | 
         | The LAMP oder LNMP Combo (nginx instead of Apache httpd) is
         | strong.
        
         | Einenlum wrote:
         | I agree. I always doubted these figures (I'm a PHP dev myself,
         | so I wouldn't mind these figures being true). I think the
         | methodology is shady. I wonder if they use what the server
         | indicates. I think some servers like Apache with php mod send
         | this information to the client in a header. But most servers
         | don't. Therefore they maybe use this as "from all the servers
         | giving a backend language information, PHP represents 77%"
         | which wouldn't be surprising. The question is how many websites
         | in your data don't give any information about the language used
         | under the hood?
         | 
         | I think we should stop using these numbers. GitHub uses ruby on
         | rails but we know it from the developer team, not from what the
         | server tells us. How many websites communicate about their
         | backend infrastructure?
         | 
         | I don't doubt Wordpress powers many websites out there. But I'm
         | tired of these figures which don't mean anything to me.
         | Especially that if you look for all job ads, PHP isn't so big
         | (except in some PHP-centric countries like France).
         | 
         | You can't just make up numbers. If you give me statistics, give
         | me the methodology you used and all the details. Otherwise I
         | suggest we all start saying Haskell powers 87% of the web.
         | After all, if you can invent what suits you, I can do the same.
        
         | chrisandchris wrote:
         | Saying 77% of the web is run by PHP and concluding therefore
         | that PHP is well-liked for websites is like telling most of
         | banking is run in COBOL and therefore COBOL is well-liked for
         | banking.
         | 
         | The conclusion has no coherence to the source.
         | 
         | I guess that most of the web runs on PHP (because it runs on
         | Wordpress) if counted by page-view. But I'm not sure that's the
         | proper measure.
        
         | is_true wrote:
         | That quote has a really big problem.
         | 
         | I run a couple of services that are accesible through an API
         | built in Symfony (PHP), but the data is generated with software
         | built with JS (event driven -> lambda, cloudflare workers),
         | Python (depending on GDAL mostly) and also PHP.
        
         | seangrogg wrote:
         | Idle musing, but this is likely correct. If someone who isn't
         | tech-minded is throwing together a quick blog in WordPress or
         | something chances are they aren't going the extra mile to
         | change the headers or add a reverse proxy just to obfuscate
         | that they're using a stock WordPress install.
        
         | dageshi wrote:
         | The vast majority of websites are probably small business
         | websites which almost all run Wordpress.
         | 
         | That number doesn't surprise me.
        
         | o1y32 wrote:
         | People have already questioned the validity of this number. Do
         | a search and you'll find people looking into this and conclude
         | that the number is very unreliable. Whether you agree or not is
         | up to you.
         | 
         | Also I want to point out that almost any time people quote
         | number about PHP's popularity, this is the only number, which
         | is strange -- for metrics like iOS market share you can always
         | find multiple numbers from multiple sources which don't fully
         | agree with each other but are within a certain range. Not for
         | this PHP number. In other words, w3tech's number is not cross
         | validated by any other source. I wouldn't use it to "prove"
         | anything.
        
         | post_below wrote:
         | It sounds like you're ultimately just saying that the 77%
         | number doesn't feel right to you.
         | 
         | I agree that it's an interesting challenge to try to determine
         | which language a large number of sites are using for the
         | backend, or at least it would be a challenge in some small but
         | maybe not insignificant percentage of cases. And no doubt
         | whichever way they solved it involved compromises.
         | 
         | But that by itself doesn't give us enough information to draw
         | conclusions about accuracy.
        
       | JonathanBeuys wrote:
       | Unfortunately, the current maintainers of PHP have not learned
       | from the success of it. And are driving PHP into the direction of
       | having the rigid structure that Java has.
       | 
       | It is so successful because people who build new things are
       | different from people who are paid to maintain old things. That
       | is why WordPress, Wikipedia and countless other successful
       | internet projects have been created using PHP and not using Java.
       | 
       | People who build new things like simplicity and elegance and
       | tools that empower them. While people who are paid to maintain
       | old things like a rigid structre which gives you the feeling of
       | "nothing can go wrong".
       | 
       | Also, people who build and run things do not like breaking
       | changes of their stack. While people who are paid to maintain old
       | things don't care about breaking changes in their stack. Because
       | they are paid to then work around those changes.
       | 
       | In the last version (8), PHP has introduced a ton of breaking
       | changes which makes the language more rigid. And therefore less
       | useful to build new things and more cumbersome to maintain:
       | 
       | It broke the order of parameters in join statements.
       | 
       | It broke calling static functions without the need to declare
       | them as static.
       | 
       | It broke adding properties dynamicly to objects.
       | 
       | It broke easy string handling for many functions where null was
       | rendered as an empty string. This is especially annoying as you
       | often get null values from the database. It makes sens to have a
       | value for "Don't know the color of the car" in the DB. And it
       | makes sense to render it as "Color: " in the user interface. The
       | easy string conversion always was one of the strengths of PHP.
       | Why is it sabotaged now?
       | 
       | Some of these changes have been objected to by the original
       | developer of PHP and long standing contributors like the author
       | of xdebeug, PHP's most popular debugger. Yet they have been
       | implemented.
       | 
       | The big danger is that this trend continues and existing PHP
       | projects will be choked to death by more and more breaking
       | changes. Changes which have to be worked around by making the
       | code of the projects more and more bloated.
        
         | jw1224 wrote:
         | PHP dev since 5.0 here. I think the severity of these breaking
         | changes is overstated.
         | 
         | I've been able to keep several large business-critical projects
         | up-to-date for years, even up to PHP 8.3, with little to no
         | breaking changes encountered.
         | 
         | PHP 8 didn't really break adding properties to objects
         | dynamically, it just deprecated one bad-practice way of doing
         | so. I remember worrying about this before upgrading, across my
         | entire project with 40+ Composer direct dependencies, there
         | were zero instances of this deprecated approach being used.
         | 
         | With other breaking changes there's plenty of notice given
         | (years, even). You can control where and how deprecation
         | notices are logged, there really shouldn't be any surprises at
         | upgrade time.
         | 
         | "Old PHP" made it easy to write buggy or unpredictable code.
         | Modern PHP feels more like writing TypeScript vs JS, there's
         | real safety and a much better developer experience now. PHP is
         | having a resurgence for good reason, yes, it's (marginally)
         | harder to keep up with, but with proper tooling (PhpStorm,
         | phpstan, etc.) the DX is leaps and bounds ahead of where it
         | used to be.
         | 
         | I thoroughly enjoy writing modern PHP. I don't have to worry
         | about the language doing unpredictable dynamic type casting
         | _unless I want it to_ explicitly. The flexibility of old PHP is
         | still there, but it's much harder to shoot yourself in the foot
         | accidentally.
        
           | JonathanBeuys wrote:
           | I think you missed my main point: That people are different.
           | 
           | I have not doubted that there are people who like the more
           | rigid structure which the current maintainers push for. I
           | actually mentioned that.
           | 
           | But the success of PHP comes from the people who like PHP the
           | way it was. Empowering them to write their own web projects
           | with the least amount of code and bloat.
        
             | jw1224 wrote:
             | > But the success of PHP comes from the people who like PHP
             | the way it was
             | 
             | I'm sure that was the case for many years, but I believe
             | the successful resurgence of modern PHP is coming from the
             | people who _want to see PHP actively improving_. Not those
             | who like PHP the way it was!
             | 
             | PHP got a nasty reputation thanks to things like the
             | "Fractal of Bad Design" site. Modern PHP has resolved
             | (effectively) all of those early critiques.
             | 
             | The _ongoing_ success of PHP comes from it continually
             | improving :)
        
               | JonathanBeuys wrote:
               | Where do you see ongoing success? That people still
               | maintain old PHP projects? That is what I said -
               | maintaining old code is done by people who are paid for
               | it and like rigid structures.
               | 
               | But people who build the future rarely use PHP now. Look
               | at jobs at YC startups:
               | 
               | https://www.ycombinator.com/jobs
               | 
               | It is rare to see PHP mentione anywhere. It's mostly
               | Python and JavaScript now.
               | 
               | Look at how lean Python's syntax is compared to PHP's new
               | obsession with "public static function {}" insida a \name
               | space\which\is\not\needed\when\you\have\a\module\system
               | tagged as "#[AllowDynamicProperties]". None of that is
               | needed in Python:
               | 
               | https://www.online-python.com/Da8nQUlAEp
               | 
               | And look at how backward compatible JavaScript is. You
               | still can run code from 20 years ago just fine.
               | 
               | The fractal of bad design post resonated with people who
               | are paid to code. Who have to adhere to "best practices"
               | and who don't mind spending time on bureaucracy. All
               | makers I know just shrugged it off with "None of that
               | get's in my way".
        
         | pwdisswordfishc wrote:
         | Wow, and here I was complaining that they are fixing the
         | language too slowly...
        
         | phendrenad2 wrote:
         | Tacit acceptance of backwards-incompatibility is a pandemic in
         | our industry, it was only a matter of time before PHP was
         | infected.
        
         | [deleted]
        
         | Supermancho wrote:
         | This move toward a more rigid and static typing pushed me to
         | move to Java (which also pays more). After 15 years of PHP and
         | over 5 in Java, I wouldn't go back now.
         | 
         | For a one-off script, I might still use a bit of PHP, if I
         | didn't have javascript.
        
       | mwinatschek wrote:
       | For me PHP was the logical evolutional step between HTML and
       | JavaScript. Those three components combined with CSS are all you
       | need to create something great on the Internet.
        
       | iLoveOncall wrote:
       | > Slack uses PHP for most of its server-side application logic
       | [...].
       | 
       | > the advantages of the PHP environment (reduced cost of bugs
       | through fault isolation; safe concurrency; and high developer
       | throughput) are more valuable than the problems [...]
       | 
       | The "high developer throughput" is really what does it for me.
       | 
       | I remember vividly when I started at Amazon (where PHP is
       | forbidden) and we were spending days building a single relatively
       | basic CRUD endpoints in Java (with Hibernate, that sucks for non-
       | trivial models), I was constantly thinking "this would have
       | literally taken 1 minute and 5 lines of code with Laravel".
       | 
       | You want your whole team to become 10x developers? Switch to PHP.
       | 
       | Between the simply incomparable frameworks that do absolutely all
       | the work for you and the fact that a simple instant page refresh
       | shows your changes, productivity is multiplied.
        
       | emodendroket wrote:
       | I feel like a lot of this is mostly a commentary on WordPress.
        
         | ekianjo wrote:
         | The article addresses that so no
        
           | emodendroket wrote:
           | Where? The article left the impression with me that without
           | Wordpress the numbers would be less impressive.
        
         | kijin wrote:
         | Which it should be, since WordPress is such a huge part of the
         | PHP ecosystem. Laravel is a distant second.
         | 
         | To talk about PHP without mentioning WordPress, whether in a
         | good light or not, would be like discussing Ruby without
         | mentioning Rails.
        
           | emodendroket wrote:
           | No doubt but it calls into question some of the reasoning in
           | the article about PHP itself being so great. Like, people
           | write a lot of VBA because of Office but I would not conclude
           | that that's because VBA is such an excellent environment to
           | work in and more because Office is a great product and VBA is
           | how you interact with it.
        
       | uconnectlol wrote:
       | [flagged]
        
       | skor wrote:
       | php is great to get things done quickly. great framework is
       | cakephp, no one has mentioned it here yet
        
       | voidwtf wrote:
       | This is great, and I'm glad for the PHP developers out there. But
       | if I go job hunting, it's not PHP skills that offer the highest
       | earning potential. At least not that I've encountered.
       | 
       | How much revenue generation occurs on PHP? I'll cede the argument
       | about the e-commerce platforms and CRMs, but I'm just not
       | convinced that PHP is where a budding developer should be
       | focusing their efforts. You enter the business/corporate world
       | and there are tons of applications out there running the world,
       | not just websites. Those applications are predominantly written
       | in languages like .NET, Java, JS/ECMAScript, Python, Rust, and
       | Go. Also, among the managed languages like .NET/Java/JS the
       | knowledge is quite transferrable and sometimes almost identically
       | named.
       | 
       | I'm not trying to bash PHP as a language, but every time I see
       | this argument it's the same. Evangelizing PHP also seems to come
       | with a requirement to mention Wordpress, Wikipedia, and Facebook.
       | I'm sure there's money to be made in PHP, and I'm sure it's a
       | great language for the internet. But learning .NET or Java is
       | likely to have a much larger window of opportunity. Also, if you
       | have a specific industry you want to work in you should be
       | looking at the language predominately sought after in that
       | industry.
       | 
       | I think this is why a lot of developers bash PHP, it's not that
       | it's a non-valid choice. It's that it has limited applicability.
       | I would never advise someone to learn PHP as their first
       | language.
        
         | ix101 wrote:
         | https://www.jetbrains.com/lp/devecosystem-2021/php/
         | 
         | Still seems to be most popular in France, doesn't appear to be
         | dying off there... Interestingly it's gaining popularity.
         | Curious why that would be.
        
           | geek_at wrote:
           | Many people who learned to code with PHP in the 2000s are
           | picking it up again as first choice for web projects since
           | they improved it so much and websites can be updated and
           | running with a simple `git pull` without restarting any
           | services.
           | 
           | I saw a video not long ago that made me have hope for the
           | future of PHP again ->
           | https://www.youtube.com/watch?v=ZRV3pBuPxEQ
        
         | gemstones wrote:
         | Right on the money. There's a reason PHP shows so high on this
         | list, and e-commerce is always mentioned. Analyses only have
         | access to public sites, and PHP's niche of blogs and e-commerce
         | have lots of publicly crawl-able pages.
         | 
         | The majority of sites may well be in something else, and the
         | majority of things that people will pay you to code may be
         | behind a login page.
        
         | zmxz wrote:
         | I was job hunting this year, I'm a long-time PHP developer
         | (since '99).
         | 
         | It wasn't the language, it's everything around it. It's knowing
         | frontend and how it works, it's knowing about cloud/operating
         | systems, databases, 3rd party integration, IAM, SSO and the
         | list goes on.
         | 
         | These skills are applicable everywhere, next to any language.
         | Compensation I was offered revolved around the ability to be
         | non-invasive towards younger teammates and to provide education
         | with emphasis on critical thinking. During the years I've done
         | this job, I learned other languages as well and I can safely
         | claim that initial language one learns has huge impact but it's
         | learning additional skills that makes up for a valuable
         | employee.
         | 
         | In the end, knowing C# but not knowing PHP bears little insight
         | into whether you're capable of listening about a requirement
         | and coming up with a solution that satisfies the need, code it
         | in such a way code can safely die one day and make in such a
         | way that additional people in the team can jump in and manage
         | it.
         | 
         | I also found a lot of job offers and opportunities. My previous
         | engagement was insurtech/fintech, there's quite a bit of PHP
         | used there (and it works well).
         | 
         | Wordpress, Magento, Facebook - these aren't the only places
         | where PHP is/was used, the world we don't hear or read about is
         | larger than the blogo-investo-googlesphere we're used to
         | reading about.
        
           | badcppdev wrote:
           | So are you saying that you didn't see a salary difference
           | between PHP roles and C# or Java roles? I've said before that
           | I think modern PHP + tools can be very productive but
           | smart/good developers will find that CV/Salary pressures
           | steers them away from PHP.
        
       | NorwegianDude wrote:
       | Ironically enough, if people actually tried PHP, many would be
       | amazed, especially at the quality frameworks. Productivity is
       | very high in something like Laravel, and compared to JavaScript
       | frameworks PHP frameworks are much more feature complete and well
       | though out.
       | 
       | I'm a big fan of trying out different stacks, and I think a lot
       | of people would love Laravel if they tried it. Give it a shot
       | using PHPStorm and Laravel IDEA (free trials for both), and see
       | what you think. Can't hurt.
        
         | hk1337 wrote:
         | > Laravel IDEA
         | 
         | Is that a fork of IntelliJ or did they just usurp the "IDEA"
         | branding from JetBrains?
         | 
         | A framework-centric IDE seems silly. Like mini cupcakes.
        
           | ofrzeta wrote:
           | Unsurprisingly it's a Laravel plugin for IDEA.
           | 
           | https://plugins.jetbrains.com/plugin/13441-laravel-idea
        
           | jw1224 wrote:
           | It's the name of a PhpStorm plugin, which adds extended
           | support for Laravel. PhpStorm is built by JetBrains on IDEA.
        
         | nilslindemann wrote:
         | Laravel annoyed me deeply when they spammed the installation
         | page with garbage like "Meet Laravel" and "Why Laravel?" I
         | stopped digging into Laravel right at this point.
         | Unfortunately, this awkward documentation style is typical for
         | most PHP frameworks, have also seen it in the TYPO3 and
         | WordPress docs.
        
         | wackget wrote:
         | As a PHP developer of 10+ years, large frameworks like Laravel
         | and Symfony still bewilder me. I really have no idea why 99% of
         | people would ever want to use them.
         | 
         | They add a layer of complexity over the top of PHP such that
         | instead of learning how to write PHP, you need to learn how to
         | write the framework.
         | 
         | Let's take an example right from Laravel's homepage:
         | Authenticating users is as simple as adding an authentication
         | middleware to your Laravel route definition:
         | Route::get('/profile', ProfileController::class)
         | ->middleware('auth');                    Once the user is
         | authenticated, you can access the authenticated user via the
         | Auth facade:                    use
         | Illuminate\Support\Facades\Auth;                    // Get the
         | currently authenticated user...            $user =
         | Auth::user();
         | 
         | As a developer, looking at that code tells me nothing. WTF is
         | the "auth" middleware? Where is it configured? What's it doing?
         | 
         | Then we come to `Illuminate\Support\Facades\Auth` - another
         | meaningless string with a seemingly arbitrary name. WTF is
         | "Illuminate" and why is it in my code? Why do I need it to
         | authenticate users?
         | 
         | So I have to go and learn all of this crap before I even begin
         | to understand what the code is doing. And for every other thing
         | I want to do with the framework I need to look up how to do it
         | "the Laravel way".
        
           | NorwegianDude wrote:
           | The reason why many use frameworks like Laravel, Symfony, RoR
           | or Django is often because they have non trivial needs. If I
           | need to do something very simple like a small blog I might
           | just throw something together on my own.
           | 
           | I personally have a large prject with a ton of code that was
           | written in the last 16 years from when I was very
           | inexperienced to now. After a while you realize that patterns
           | are important, and you start building more and more features
           | to make development and maintenance simpler and faster.
           | 
           | Here is a list of things I created over some years for that
           | project: - Authentication system that supported different
           | types of login. - Pretty routes. - Simple dependency
           | injection container. - Emailing. - A templating system. - A
           | scheduling system. - A worker pool. - Reusable forms. -
           | Simple DB migrations in code. - Caching system. - A file
           | storage system. - Data seeding. - Testing. - Websockets. -
           | Asset bundling and versioning. - Localization. - Payment
           | integrations. - +++
           | 
           | Sure, I could do it the JS way and find different packages
           | instead of doing it myself, but I don't want to rely on a
           | bunch of projects as that quickly can become maintenance
           | hell.
           | 
           | After a while you realize that you're basically reinventing
           | the wheel. Is Laravel and Somfony complex? Yes. Does it
           | sometimes seem like magic? Yes. Is it hard to use, modify or
           | figure out how it works? No.
           | 
           | You might not know why 99 % would want to use them, but I'd
           | agrue that most probably should when the project achives some
           | complexity. That way you can reap the benefits of the work
           | and experience of thousands of contributors behind these
           | projects.
           | 
           | I am one of those "I want to know what happens in the
           | background" people too, and it's not that hard to figure out
           | how Laravel works if you want to know. But most developers
           | are not interested in how the framework they are using really
           | works. The questions you have about what the auth middleware
           | is, how it works, and what the Illuminate namespace is
           | for(Laravel) is easy to figure out by checking the docs.
           | 
           | Laravel is definetly an opinionated framework, but personally
           | I think most of the options are good ones.
        
           | pavel_lishin wrote:
           | > _They add a layer of complexity over the top of PHP such
           | that instead of learning how to write PHP, you need to learn
           | how to write the framework._
           | 
           | To be fair, you could say this about many frameworks in many
           | languages; Ruby on Rails is the first obvious example of
           | this.
        
             | Capricorn2481 wrote:
             | These are more exceptions than rules. Rails, Laravel, and
             | Django are the three massive frameworks that are languages
             | themselves, so learning them as an introduction to their
             | programming languages can be confusing for newcomers.
             | 
             | It seems, to me, that small server frameworks with
             | middleware are what's in vogue right now. Flask, Express,
             | Slim. C# added minimal API recently.
        
         | MrVandemar wrote:
         | Well, I used to do PHP back in the day, and I know the language
         | has changed and evolved a lot, but I've looked at Laravel
         | thinking it would be something cool and interesting and
         | productive, and it seems bewildering and bloated. Doing one
         | simple thing seems to take a mountain of incomprehensible
         | overhead.
         | 
         | Not to say it's bad, but even with some experience, I couldn't
         | grok it.
        
           | jw1224 wrote:
           | > Doing one simple thing seems to take a mountain of
           | incomprehensible overhead.
           | 
           | If you just need to do one simple thing, don't use a
           | framework :)
           | 
           | If you need to _lots_ of simple (or complex) things, in an
           | organised manner across a single project, Laravel is great!
           | 
           | (Having said that if you have an example of what you were
           | referring to, I'd be curious)
        
         | severino wrote:
         | Out of curiosity, in your projects where you use PHP with
         | frameworks such as Laravel, do you do server-side rendering, or
         | SPA applications? I prefer the former but I wonder what's the
         | trend now for the people into Symphony, Laravel, etc.
        
           | NorwegianDude wrote:
           | I have mostly used SSR, but in the last years I'm sometimes
           | using Inertia with React/Vue/Svelte and SSR too. Not sure if
           | there are any clear trends. Personally I prefer plain old
           | blade templates, and I only use FE frameworks if I think it
           | makes sense.
           | 
           | I don't know how the experience is with Livewire, but I've
           | heard a lot of people like that too.
           | 
           | The common options with Laravel is plain blade templates[1],
           | Intertia(React/Vue/Svelte, SSR optional)[2] or Livewire[3].
           | 
           | [1] https://laravel.com/docs/10.x/blade
           | 
           | [2] https://inertiajs.com/
           | 
           | [3] https://livewire.laravel.com/
        
           | jw1224 wrote:
           | Laravel has a dedicated marketing page especially about this:
           | 
           | https://laravel.com/frontend
           | 
           | I personally use different approaches in different projects,
           | but it works great both ways. Inertia is really excellent
           | with frontend frameworks like React/Svelte, whilst Blade is
           | brilliant for server-side templating too.
        
       | kyriakos wrote:
       | I love and use php but this article feels more like propaganda.
        
         | [deleted]
        
         | bawolff wrote:
         | This doesn't make sense as a criticism. What do you think a
         | blog post or an essay is?
        
           | peteforde wrote:
           | To declare that blog posts, essays and propaganda are
           | functionally the same thing is wickedly cynical, don't you
           | think?
        
             | bawolff wrote:
             | No i don't. Perhaps we have a different definition of the
             | word propaganda?
        
         | aaviator42 wrote:
         | There's a lot and hate of criticism of PHP out there, so some
         | praise and sane opinions are nice to balance it out.
        
           | kyriakos wrote:
           | Hate almost always comes from people who haven't used PHP in
           | a very long time or touched it briefly at some point.
           | Fanboyism serves no purpose. Experienced developers
           | understand that programming languages are just tools each
           | with their own trade-offs.
        
             | rvnx wrote:
             | A good programmer doesn't really care about the langage
             | itself, but rather whether the language is the right tool
             | for the job.
             | 
             | For example, Erlang is painful to adapt to, but in some
             | cases (example: if you build a Messenger app) it will be
             | the best.
             | 
             | It doesn't mean that Erlang is a bad language at all, it is
             | designed for a main purpose in mind.
             | 
             | It's normal to see junior developers and low-quality
             | packages in PHP, JavaScript, Java or Python, it's because
             | these languages are well-documented and rather accessible.
             | 
             | There is no point in making a language needlessly complex.
        
               | kyriakos wrote:
               | It's not any different to my point. You can use a hammer
               | to hammer in a screw it doesn't make it fit for the job
               | but it will work up to a certain extend. Similarly you
               | can make a messenger app in PHP but you are better off
               | using Erlang or maybe Node.
        
               | rvnx wrote:
               | Absolutely agree.
        
             | bawolff wrote:
             | > Experienced developers understand that programming
             | languages are just tools each with their own trade-offs.
             | 
             | Which is literally what the article said.
        
       | oneplane wrote:
       | It looks like a report on quantity of instances (sites,
       | frameworks, packaged setups) but doesn't go into other metrics
       | like traffic load, users, PnL or other money-metrics. Say the top
       | 100 websites were all to use PHP, that would be a very different
       | story than none of the top 100 websites using PHP, but neither is
       | reported. We have some "we are in the top 500" and "we have
       | billions of page views", but not much else.
       | 
       | That said, how good or bad a language is might not be quantified
       | or qualified to a point where all audiences are happy. How it's
       | used vs how it's structured, where it's used vs. how much money
       | it's making can all mean different things to different people. If
       | you look at it from an academic (CS) perspective it might not
       | matter how much money it makes if it lacks some scientific
       | nuances. But the same works the other way around as well; it
       | doesn't matter how cool COBOL, FORTRAN or lisp is if you can't
       | run your massive eCommerce web app with it (there is a joke in
       | here somewhere).
        
       | csomar wrote:
       | As an ex-PHP developer (almost 10 years now), I do not miss it.
       | As a language, it is a scripting language with an okay
       | interpreter. But as an eco-system, it is a hot mess. It has both
       | the worst software developers (and I was one of them) as well as
       | the worst clients (and the cheapest, regardless of geography).
       | 
       | It is not a surprise that PHP is running the web. That's because
       | WordPress made sites/e-commerce accessible to the average Joe.
       | Despite the massive security issues with these setups, it has
       | enabled a large number of people to run businesses.
       | 
       | But if you are a software developer, I'd strongly advice you not
       | to do PHP.
        
         | bbarnett wrote:
         | Modern PHP may as well be a new language. But then node came
         | along. It's almost like PHP users couldn't stand a clean
         | ecosystem.
        
           | delfinom wrote:
           | Clean??????????
           | 
           | Dude, Node is as broken as PHP. And it starts from having no
           | standard library leading to hell like leftpad and general
           | software supply chain holes that PHP never had in the same
           | quantity.
           | 
           | It isn't clean. Node was just shinier and had more
           | applications to leveraging it for a shiny frontend.
        
             | mehphp wrote:
             | I think that's what he's saying: That they jumped from php
             | to another hot mess. At least that's how I read it.
        
           | csomar wrote:
           | I don't think the language is the problem. As bad as it is,
           | it is certainly more well thought that the original
           | JavaScript. But PHP is used mostly by "businesses" with no
           | budget and this is essentially the absolute rock-bottom of
           | the "software" industry.
        
             | acdha wrote:
             | I think the language is the problem in some key areas. I
             | started using PHP at the tail end of 2.x and remember
             | trying to get a couple of endemic sources of bugs fixed in
             | 3.x: register globals, requiring constant diligence NOT to
             | ignore errors, and inconsistencies around things like
             | parameter ordering for array functions or magic type
             | conversion. Every time, it got pushback from someone saying
             | it'd break too much code - at a time when there were
             | billions of lines less PHP in the world, and when those
             | were causing high profile security issues and app failures.
             | I ditched PHP in the 2000s after getting tired of that, but
             | picked up a legacy project a couple of years ago. Register
             | globals is finally gone but everything else which I
             | remember causing having to carefully train developers to
             | avoid in the 90s is still a rake in the grass today.
        
           | mickael-kerjean wrote:
           | NodeJS is the new PHP aka it's the first language someone who
           | want to "web stuff" pick up. A decade ago most blog post
           | about PHP had major security issues because the people who
           | wrote those posts were just learning the ropes and copying
           | each other in the same way most tutorial about react these
           | days don't care about cleaning themselve up, unit testing and
           | all that stuff that make the difference between a cowboy and
           | a software made with quality in mind.
           | 
           | The state of JS is maddening, whoever spit on PHP but love JS
           | will need to explain why an hello world from create react app
           | has 800 dependencies in the node_modules, why do we keep
           | using babel when most browser is already supporting es6 fine
           | and why do we have some many way to import modules. PHP had
           | its issues which got fix over time but we can't say the same
           | with JS.
        
             | hombre_fatal wrote:
             | I wonder how many more years it will take HN to stop
             | pointing out client development idiosyncrasies when
             | comparing Javascript to a language like PHP that has no
             | client development story at all when supposedly trying to
             | compare server-side DX.
        
         | voidwtf wrote:
         | This just reminds me of what originally got me into PHP as a
         | teenager. Creating a site for our gaming community in PHP-Nuke
         | was all too easy. Extending it with plugins, and eventually
         | writing my own plugins to show live data from our game server.
         | 
         | Now I look back on PHP3/PHP4 with disgust. Globals, function
         | names, massive pieces of code right in the middle of HTML,
         | shell_exec.
        
           | JuanPosadas wrote:
           | What's the closet think to a modern PHP nuke?
        
           | doublerabbit wrote:
           | > Globals, function names, massive pieces of code right in
           | the middle of HTML, shell_exec.
           | 
           | And they're not inherently bad.
           | 
           | PHP made the internet fun. Anyone could get going with a PHP
           | enabled host with by creating an HTML document starting with
           | <?php> and have a working something that the world could see
           | by end of the day.
           | 
           | Today's web development feels like such a drag. In that you
           | need to choose the scaffolding, create the scaffolding, wait
           | for the concrete to dry, drill holes for the infrastructure
           | and then construct the infrastructure.
           | 
           | When you then go to connect the infrastructure you find that
           | one of the girders has buckled which requires a patch-up or
           | refactor. Someone's misprinted the blue-prints and the cable
           | ferret has gotten lost down one of the connectivity holes.
           | You then discover that a new scaffolding company has come to
           | town so your construction is now obviously out of date.
           | 
           | PHP enabled you to have something cool in days. Nowadays you
           | spend days just trying to setup react. my two cents.
        
             | icedchai wrote:
             | This matches my experience. In the old days (mid-2000's) I
             | did a ton of PHP freelance work. This was done mostly with
             | home grown "frameworks", built around HTML form to MySQL
             | database mapping and CRUD operations. This was before REST
             | APIs were really a thing, everything was page driven ("SSR"
             | in today's terms, I guess.) For anything dynamic, we'd use
             | JQuery, make an ajax call, return partial HTML, and inject
             | it into the page. It was actually incredibly productive. I
             | later moved on to Laravel and ditched the home grown stuff
             | for newer projects.
             | 
             | I don't do PHP work much these days (permanent "working
             | from home" made me not want to do any extra work from home
             | after hours), but it felt incredibly productive compared to
             | the more modern tech I've seen in my day jobs. There's a
             | lot of crap to wade through nowadays. A typical small
             | project might have a React front end, Python back end, REST
             | API's, documentation, cloud deployments, on-and-on. Web
             | development isn't fun anymore.
        
         | jpalomaki wrote:
         | PHP was the Visual Basic 6 for web. People without proper
         | training and theoretical knowledge just went and did stuff.
        
           | blantonl wrote:
           | and made millions of dollars
        
             | rexreed wrote:
             | billions
        
               | joshmanders wrote:
               | Considering Facebook is PHP (oh shut up Hack is PHP too)
               | we could even say trillions.
        
             | Jedd wrote:
             | It relocated wealth, but it did not create it.
             | 
             | There are lots of industries that are _lucrative_ , but
             | there's clearly no linear correlation to quality or
             | societal benefit.
        
               | JuanPosadas wrote:
               | > did you make the pie bigger or did you take a bigger
               | slice?
               | 
               | I think PHP did make the pie bigger, but there won't be
               | shortage of companies who used PHP to only take a bigger
               | slice.
        
           | Angostura wrote:
           | Empowered a generation to get stuff done.
        
             | dizhn wrote:
             | I saw a webpage in the early 2000s that when I clicked
             | something, it remembered the data on the next pages. Think
             | simple counter. I checked out the site and it claimed to be
             | using something called PHP which even free hosts of the
             | time provided. How is this not enabling right?
             | 
             | I had a similar "simple counter" moment at a later date and
             | the tech was AJAX. I am yet to have a similar moment after
             | that. Perhaps WASM based interfaces? But it's not the same.
             | Maybe I am not the same.
        
             | ur-whale wrote:
             | And leaving a steaming pile of unmaintainable shite being
             | them.
        
               | joshmanders wrote:
               | Can we see your non-steaming pile of totally maintainable
               | non-shit for comparison?
        
           | JodieBenitez wrote:
           | I think this is a sound analogy. I certainly recognize myself
           | in the person without proper training and theoretical
           | knowledge that just went and did stuff. Of course I changed
           | and so did my tooling.
        
             | joshmanders wrote:
             | If it wasn't for how easy it was to get started and learn
             | PHP back in 1998 when I started, I'm pretty sure I'd have
             | gone to culinary school and became a chef instead of an
             | software engineer.
             | 
             | I owe everything I have to Rasmus and his beautiful
             | "shitty" language.
        
       | samsquire wrote:
       | Things I really like about PHP:
       | 
       | Once the file is on the filesystem, it's deployed.
       | 
       | Each invocation to run PHP is stateless and it parallelises
       | effectively. (There's no communication, synchronization between
       | PHP instances.)
        
         | Capricorn2481 wrote:
         | It is definitely refreshing to simply upload a file via FTP and
         | it updates your server. But it's this interpreted nature that
         | makes PHP one of the slower languages in terms of throughout. I
         | know, don't prematurely optimize, but there's a reason other
         | languages don't do it this way
        
       | fevangelou wrote:
       | As the "Pitch Meeting" producer guy would say: PHP is tight!
        
       | thrusong wrote:
       | I love PHP and MySQL. I'm self taught and I've been writing it
       | since 2007. It has helped me solve real problems at every job
       | I've had since which has helped me advance my career in
       | tremendous ways.
       | 
       | I know PHP is not perfect and I've definitely contributed some
       | hot messes of code in the past as I figured things out. Sorry...
       | 
       | PHP has let me code anything I've wanted so far, so it's a really
       | powerful tool for me.
       | 
       | I'm the guy who built an automated home cinema using PHP and
       | MySQL: I hit a button on a website and it tells a Raspberry Pi to
       | start the desired show.
       | 
       | It selects a Dolby ad, some sort of vintage ad like dancing hot
       | dogs, a couple of trailers, and the feature. It brings the lights
       | up for the credits.
       | 
       | All PHP: https://www.youtube.com/watch?v=Q7YEVGWJjvI
        
       | cloudking wrote:
       | At the end of the day if your software works and users like it,
       | does the programming language even matter?
        
         | agumonkey wrote:
         | It does, language comes with culture, I'm polyglot and the
         | amount of horrors I've seen in php3/4 days was on par with
         | legacy cobol.
         | 
         | It was too sweet on effectful code around random maps (what's
         | not to like, you can do whatever and spend hours trying to find
         | the right combination of stdlib array_ functions until
         | something happens).
         | 
         | Of course things change after the nonphp6. But if someone only
         | knows and love php I'll check twice before working with him.
         | I'm actually dealing with someone like that right now.
        
           | oaiey wrote:
           | Yeah, the "culture" had its technical issues. But in real
           | culture PHP people are typically good mooded, friendly and
           | humble fellows.
           | 
           | So culture is a plus thing. Because the technical mishaps are
           | there in any community with size (looking at you JavaScript)
        
         | wiseowise wrote:
         | If you do it 40 hours a week - absolutely.
        
         | kyriakos wrote:
         | It's very unlikely these days for a medium sized and above
         | software project to be written 100% in a single language.
        
         | kxrm wrote:
         | I agree that it should not matter but there are people out
         | there who really have strong feelings about PHP. I understand
         | those strong feelings because PHP was very popular since it was
         | on every shared host and it was super easy to quickly whip up
         | scripts that render dynamic pages back in the day. That ease
         | had consequences that PHP is trying to dig out from under to
         | this day. I personally reach for PHP first for all my personal
         | web projects. It's where I am most comfortable.
         | 
         | I write C++, Rust, Python, C#, and JS in various capacities
         | both personally and professionally and I always go to the first
         | language I learned whenever I want to prototype, PHP.
         | 
         | That said, I agree with the sentiment you are expressing. If
         | the app works, and people enjoy using it, the underlying
         | language only matters to other devs who might work on it and
         | that is it.
        
           | trilbyglens wrote:
           | Still do this day I don't know of any serverside language
           | that you can just drop files into to update.
        
             | quickthrower2 wrote:
             | Next.js is a bit like this. In at least it does the 1-1
             | file to route mapping. Not drop in on the server but is so
             | on the dev machine.
        
         | ludwik wrote:
         | It does matter. I can't offer an opinion on the modern state of
         | PHP since I'm not familiar with its recent developments.
         | However, it's true that certain programming languages and
         | frameworks can facilitate writing maintainable, secure code,
         | while others might naturally foster problematic, insecure code.
         | It isn't to say that you can't write good code with them, but
         | it can be unreasonably difficult.
         | 
         | Take, for instance, the PHP environment around the time the "a
         | fractal of bad design" (https://eev.ee/blog/2012/04/09/php-a-
         | fractal-of-bad-design/) article was published -- which also
         | coincides with the last time I worked professionally with PHP.
         | During that period, PHP was plagued with inconsistencies, a
         | tendency to hide errors, and insecure default settings, all of
         | which encouraged writing bad, unmaintainable, and insecure
         | code. Those aspects truly matter.
        
         | dvdkon wrote:
         | Maybe not for the user, at least not directly, but developer
         | experience is something to optimise for.
         | 
         | PHP is also the one language whose choice can make an impact on
         | users' experience, since its shared-nothing (sans caches)
         | runtime model is almost CGI-like and can, in my experience,
         | lead to higher latency, as each request simply does more. Maybe
         | some experienced PHP devs can tell me how they combat this?
        
           | monkey_monkey wrote:
           | If you need it, Swoole and Roadrunner exist
        
           | bawolff wrote:
           | > since its shared-nothing (sans caches) runtime model is
           | almost CGI-like and can, in my experience, lead to higher
           | latency, as each request simply does more. Maybe some
           | experienced PHP devs can tell me how they combat this?
           | 
           | I mean, you kind of answered your own question - they use
           | caches like apcu or memcached. Apcu is just shared memory so
           | its basically ends up being very similar to languages that
           | don't do shared nothing.
        
           | mattnewton wrote:
           | The most common defense I hear here is that the inefficiency
           | just never mattered.. and if it did it was because the
           | product was a blockbuster success and you could hire to
           | rewrite the slow parts or adopt hack or whatever.
        
             | oaiey wrote:
             | It does not when your project has not 100s of users hitting
             | at the same time. And honestly, which application survives
             | that at first sight and does not need to solve the problem
             | one level higher (like building for load balancing,
             | writer/read databases, etc ).
        
           | 9dev wrote:
           | There are multiple options by now. For one, PHP got a JIT
           | compiler a while ago. That, in combination with the existing
           | opcode cache, actually causes PHP to outperform its
           | interpreted competitors in most cases.
           | 
           | Additionally, there are several application server
           | strategies, sometimes with a process manager that keeps
           | preloaded request workers at hand, sometimes hosting an event
           | loop, and sometimes a request worker that gets partially
           | reset after handling requests. This yields performance
           | comfortably comparable to optimized Node.js apps.
           | 
           | In general, PHP has a highly optimized runtime, and we didn't
           | even really touch caching yet. Trust me when I say
           | performance is not one of the problems PHP poses :)
        
             | oaiey wrote:
             | And not to forget traditional web server caching. Since
             | they mimick html files on the server, doing your app right,
             | you can use the very mature caching options in the web
             | server / proxies.
        
       | [deleted]
        
       | ahoka wrote:
       | The internet is full of spam sites made with Wordpress. This
       | means nothing for PHP as a language.
        
         | oaiey wrote:
         | Spammers are also coders. We all do not like them, but they
         | are. Their pages and system are part of the system.
         | 
         | If you are spammer and read this: search a different job and
         | drop all tables before you leave!
        
         | ekianjo wrote:
         | The internet is not just wordpress sites...
        
           | popcalc wrote:
           | But it overwhelmingly is.
        
             | ekianjo wrote:
             | 43 % does not sound like it qualifies for the use of
             | overwhelmingly
        
       | _rm wrote:
       | I've always liked PHP. You wouldn't pick it for your job
       | interview's coding test if you had a choice (Python all the way
       | there), but it's so intertwined with the internet and what we've
       | learned about programming over the years. First mover advantage
       | kind of deal.
       | 
       | And I've never had to deal with ESM/CJS/AMD whatever module
       | nonsense with PHP. No transpiling anything, just edit and
       | refresh. And so many useful functions out of the box
       | (array_column anyone?).
       | 
       | I think its bad rap comes from its ubiquity. Pretty much any
       | existing website I've had to work on has been a putrid mess.
       | That's just the way codebases go unless you're a SaaS with a CTO
       | who's hell bent on preventing that.
       | 
       | And since most of these putrid messes have been based on PHP, due
       | to it's age and ubiquity, people blame it, due to observation
       | bias.
        
         | tommica wrote:
         | I've gotten a lot of value by being able to go to a library in
         | my vendor folder, and add some var_dumps in there to figure out
         | where my code is going wrong. The way the dependencies works is
         | magnificent.
        
           | djbusby wrote:
           | Xdebug?
        
         | danmur wrote:
         | I haven't used it for a long while, but I did a LOT of PHP5,
         | several years. In my opinion PHP4 was horrific (from a
         | language/standard library perspective, most languages you can
         | get what you want done regardless of that), a lot of it carried
         | over into PHP5 despite being a lot better (e.g. see
         | phpsadness). Then the fiasco that was 6/7/whatever made it
         | really hard to have confidence in the future of PHP.
         | 
         | No idea how recent PHP is. It's hard to escape those opinions
         | that formed fairly widely in the industry is, though.
        
         | matthiaswh wrote:
         | PHP is akin to, I don't know, the Subway (fast food restaurant
         | chain) of programming languages?
         | 
         | You don't hear too much about it. You almost never notice it
         | unless you're actually looking for it, unlike McDonald's with
         | its ostentatious golden arches.
         | 
         | It's popularity is waning. But it's still everywhere. [0] There
         | are a hundred other sandwich chains that have tried to do it
         | better but none have managed the ubiquity of Subway.
         | 
         | People like to look down on it and espouse the alternatives,
         | but when it comes down to it fast food can only ever be so
         | good.
         | 
         | I guess that means that JavaScript is McDonald's?
         | 
         | [0]
         | https://en.wikipedia.org/wiki/List_of_the_largest_fast_food_...
        
           | lproven wrote:
           | That's a fun list.
           | 
           | Of over 100 I have only heard of 1/3: 35 in total.
           | 
           | I have only ever been into and eaten anything from half of
           | those.
           | 
           | So fully 2/3 of the list I've never even _heard_ of.
           | Interesting.
        
           | nolok wrote:
           | > It's popularity is waning.
           | 
           | I don't think that applies though. If anything, laravel is
           | pushing PHP into another "golden age" not seen since code
           | igniter 2, with again a framework that does things not quite
           | how they should be under the hood, but definitely how people
           | need them to be to be fast and efficient, except this time
           | backed up by a proper package management system, a much
           | better and stronger language and an ecosystem based on
           | reusable modules.
           | 
           | Does it have the favor of the modern hype or new language
           | seeker or anything like that ? No, absolutely not, but when
           | has PHP ever had that ?
        
             | bbarnett wrote:
             | There will be no golden age for anything using node.
        
           | outofpaper wrote:
           | With this analogy python would be the Ikea. You can go for
           | the fast food (site scripting) or you can get really invested
           | and build out your ML modules with it at scale ( remodeling a
           | decking out your kitchen)
        
         | [deleted]
        
         | gleenn wrote:
         | Bad rap comes from the inconsistency of the early APIs. The
         | ability to interleave code and HTML was also tacky and never
         | taken seriously but I think touted highly by some as a killer
         | feature. The language is very unplanned, go look at an equality
         | chart for PHP, it makes JavaScript blush as well.
        
           | bennyp101 wrote:
           | "The ability to interleave code and HTML was also tacky and
           | never taken seriously" - That was the whole point of it! The
           | day I found PHP and could leave behind the cgi-bin and SSI it
           | became my favourite thing - and has paid me well for the last
           | 20+ years :)
        
             | techsupporter wrote:
             | Putting HTML inside of scripted code blocks was legendary
             | back in the day and every web-oriented language did it. I
             | guess people have already forgotten about ASP and
             | ColdFusion. Being able to for each an array into table
             | rows? Game changing.
        
               | n3storm wrote:
               | I have been coding in coldfusion (openbluedragon) on
               | 2012. Still lurks in my dreams. I refactored to
               | components (objects) some functionalities as a POC, it
               | did not fit well with the main programmer.
        
           | iLoveOncall wrote:
           | > The ability to interleave code and HTML was also tacky and
           | never taken seriously
           | 
           | And yet people would take a bullet for React and the JSX
           | templates.
        
             | _rm wrote:
             | Funny how "server side rendering" became a hot new thing
             | too.
             | 
             | I was so confused when I heard that, "like... a HTML
             | file?".
             | 
             | Keep going at this rate and we'll be using frames again.
        
               | jiggawatts wrote:
               | > using frames again.
               | 
               | That's pretty much what htmx is...
        
               | sublinear wrote:
               | > "like... a HTML file?"
               | 
               | Serving a static HTML file is not server-side rendering.
               | 
               | It's much dumber than that. The people advocating for SSR
               | want the server to respond with HTML generated based on
               | whatever is in the request.
        
               | fjfuvucucuc wrote:
               | So like PHP?
               | 
               | This thread is so cope.
        
               | [deleted]
        
             | trilbyglens wrote:
             | I too find this hilarious. Not because I want to defend
             | PHP, but moreso that I personally sort of despise react and
             | it's whole ecosystem. I've never liked writing code less
             | than when dealing with a spaghetti monster react app.
        
               | omnimus wrote:
               | Well React was born in Facebook which was famously PHP
               | codebase. It makes sense.
        
             | parminya wrote:
             | JSX and PHP are actually seriously different. When you
             | break out of PHP, you're just outputting text to standard
             | output. When you're using JSX syntax, you're constructing
             | Javascript objects that can be manipulated using standard
             | javascript techniques. Anyone who believes they're
             | comparable seriously doesn't understand the task that is
             | before them.
        
               | fjfuvucucuc wrote:
               | Oh please, I professionally use both daily (enjoy them
               | both), but even I can see JSX is just PHP with extra
               | steps.
        
               | thewix wrote:
               | Though not JSX, with TSX you get type checking with your
               | markup.
        
               | wildrhythms wrote:
               | My reading of this thread is that people are comparing
               | JSX as a _templating language_ to PHP as a templating
               | language, splicing PHP  <? ... ?> into HTML like how we
               | have { ... } in JSX. At the end of the day React lets you
               | write a function that returns HTML just like a PHP file.
        
           | chx wrote:
           | > The language is very unplanned, go look at an equality
           | chart for PHP, it makes JavaScript blush as well.
           | 
           | This has been fixed in PHP 8.
           | https://wiki.php.net/rfc/string_to_number_comparison
        
             | xigoi wrote:
             | > make non-strict comparisons more useful and less error
             | prone, by using a number comparison only if the string is
             | actually numeric. Otherwise the number is converted into a
             | string, and a string comparison is performed.
             | 
             | That... makes it even worse.
        
               | slim wrote:
               | why?
        
               | xigoi wrote:
               | Because now the behavior of comparison depends on whether
               | the string looks like a number.
        
               | chx wrote:
               | Arguably 48 == "48" should be true. If this doesn't work
               | for you, stick to ===.
        
               | xigoi wrote:
               | Thank you, I'll stick to languages where you can't just
               | compare numbers and strings without an explicit
               | conversion.
               | 
               | Also, should 48 == "48.0" be true? How about "048",
               | "48.", "0x30", " 48 ", "48foo", "3*16", "XLVIII", "forty-
               | eight"?
        
           | tinus_hn wrote:
           | The bad original library, the original lack of features that
           | help against bad coding practices and the fact that it is so
           | accessible to beginner programmers that you'll find a lot of
           | beginner code.
           | 
           | The ability to mix html and code means it's extremely easy to
           | get started which is the big strength.
        
           | tonyedgecombe wrote:
           | I'd love to see a modern PHP without the language quirks and
           | with a decent standard library.
        
             | phyrex wrote:
             | https://hacklang.org/
        
           | bawolff wrote:
           | > The ability to interleave code and HTML was also tacky and
           | never taken seriously but I think touted highly by some as a
           | killer feature.
           | 
           | And yet people seem to keep inventing variations of this as
           | "templating" languages.
        
             | pwdisswordfishc wrote:
             | That presumably take care of the escaping rules and grammar
             | of the output language, unlike the giant string
             | concatenator that is PHP.
        
               | plorkyeran wrote:
               | Yeah, a big problem with the traditional PHP-in-HTML
               | approach to generating web sites is that it's one of the
               | areas where PHP _hasn 't_ dramatically improved since the
               | early days. Later templating engines learned from the
               | problems people encountered with PHP and were built to be
               | aware of the output format, and PHP never did that. A lot
               | of work was put into writing templating engines in PHP
               | that in retrospect really should have instead been a
               | language mode for PHP itself.
               | 
               | We would have seen dramatically fewer bugs and injection
               | attacks over the years if PHP had made <input
               | value="<?=$value?>"> a perfectly safe and normal thing to
               | write back in 2005.
        
         | kxrm wrote:
         | > You wouldn't pick it for your job interview's coding test if
         | you had a choice (Python all the way there),
         | 
         | I do actually pick it for several reasons.                 1. I
         | want to know if the environment I am going into is pragmatic
         | about languages.  If you are going to refuse to continue
         | working with me over something so minor as PHP then we aren't a
         | culture fit.       2. I want to showcase my best.  I know this
         | language in and out.  It's the first language I learned and I
         | have the greatest ease of building algorithms with it.  I've
         | had interviews where I was asked to do something with PHP that
         | PHP did not support and I found ways to make it work.       3.
         | In some ways I love the conversation that comes with positive
         | interviews when using it.  Oftentimes the interviewer isn't
         | very familiar and it sparks discussion on the languages
         | benefits and drawbacks further showcasing my skillset.
         | 
         | Sure as we progress along in the interview process I will
         | switch to whatever language the company uses primarily but if I
         | get a choice I always choose PHP.
        
           | [deleted]
        
           | _rm wrote:
           | That's a good point, I imagine doing that would screen out
           | companies run by language snobs.
           | 
           | My go to for this is to say "I don't think Typescript is
           | needed most of the time". The snobs look at you like you just
           | farted in their face.
           | 
           | But having done some coding interviews where time and space
           | complexity were a factor, I found it easier to succeed with
           | Python.
        
             | JuanPosadas wrote:
             | > "I don't think Typescript is needed most of the time
             | 
             | This is a terrible example, typescript (especially in 2023)
             | is basically free with most setups (including vanilla) and
             | easy to ignore for velocity then optionally enforce
             | typechecking later.
             | 
             | A much better hill to die on would be large
             | frameworks/tooling like react/angular/webpack.
        
           | aaviator42 wrote:
           | Your comment articulates my thoughts on PHP very succinctly.
           | Especially the culture fit bit. PHP is so insanely pragmatic
           | that if someone looks down on it due to false preconceived
           | notions then they're not the kind of person I can probably
           | work happily with anyway.
           | 
           | It's also the thing I'm best at!
        
             | oaiey wrote:
             | And they are humble. They know their state, the flaws in
             | their language and the long problematic history they have.
             | 
             | They cherish their languages but are not fanatics.
        
               | blowski wrote:
               | PHP has its fair share of snobbery as well. Non-framework
               | devs look down on Symfony, who in turn look down on
               | Laravel devs, and everybody looks down on WordPress devs.
        
               | [deleted]
        
               | chx wrote:
               | > and everybody looks down on WordPress devs.
               | 
               | Maybe because they have been actively sabotaging progress
               | and dissing those pushing for progress? gophp5 in 2008
               | pushed everyone but Wordpress off PHP4 and some Wordpress
               | core committers as recently as 2017 have called gophp5 an
               | "abysmal failure" despite it was anything but.
        
               | jtreminio wrote:
               | I would look down on any group not using a framework, or
               | rolling their own.
        
               | dasil003 wrote:
               | Every language does, I think it comes with the territory
               | of any domain where fine details matter. The trick is to
               | cultivate your own opinions and approach to excellence,
               | but recognize there are a lot of different things to
               | optimize for, and no one likes a comic-book guy attitude.
        
               | fjfuvucucuc wrote:
               | I started out as a symfony snob. Got sick of writing java
               | in PHP so I picked up laravel. Got sick of having to
               | modify my code every time Taylor huffed some new shit so
               | I started building things using WordPress.
               | 
               | It's so refreshing knowing that my websites auto update
               | themselves and I never have to update them unless there
               | is a legitimate reason to do so.
               | 
               | Backwards compatibility is the ONLY thing I care about in
               | a framework. Life's too short to babysit some frameworks
               | ideas of how my code should work ten years after building
               | the damn thing.
        
               | hk1337 wrote:
               | Symfony and Laravel have their proper usages.
               | 
               | I used to be Symfony snob too but tried Laravel and I
               | definitely see its strengths.
               | 
               | Laravel was not the right choice with our homegrown, non-
               | framework app, with an existing schema.
        
               | fjfuvucucuc wrote:
               | Yea, don't debate that. I just personally have no
               | tolerance for the behaviour of these framework developers
               | and the level of work they impose on their users.
               | 
               | For a business that has engineers to manage this day to
               | day it's less of an issue. For building things you want
               | to live online untouched for a decade it's just not an
               | option.
               | 
               | Laravel is nice to build stuff fast in one particular
               | way. It's awful to maintain and heaven forbid you have a
               | different idea about how things should be done.
        
           | l5870uoo9y wrote:
           | Not to nitpick but choosing a programming language isn't a
           | minor decision nor is switching programming style, e.g. OOB
           | vs FP. Of course I agree with the intend and I too want to
           | work in pragmatic and explorative programming environments
           | trying out different programming languages and styles
           | depending on the project.
        
             | dncornholio wrote:
             | If you worked long enough, language or code style are
             | beginning to become almost completely irrelevant
        
             | coldtea wrote:
             | > _Not to nitpick but choosing a programming language isn
             | 't a minor decision_
             | 
             | In the grand scheme of things, talking solely about
             | software projects not life in general, it kind of is.
             | 
             | Most modern languages, are interchangeable, and projects of
             | most kinds have been done with all of them succesfully.
             | 
             | As long as the programmers for the chosen language are
             | available, and the libs you want are there, for startups
             | doing some web backend for example, it doesn't really
             | matter if it's Python, Ruby, JS/Node, PHP, C#, Go, Java,
             | CL, Kotlin, Clojure, and so on.
        
               | sodapopcan wrote:
               | I don't think "interchangeable" is the right word here.
               | In some cases, perhaps, but different languages have
               | different idioms and, since you have Clojure on there,
               | different paradigms. If the individual coming into the
               | new language is diligent about learning how to properly
               | work in it, then all is well. If they decide to try and
               | force what they already know into the new language, that
               | is problem. I've experienced the latter far more often
               | than the former. If you're working for a feature factory,
               | though, I guess it doesn't matter.
        
               | cutler wrote:
               | Working with Clojure is a world apart compared with any
               | of the others listed.
        
               | tacker2000 wrote:
               | I disagree. There will be lots of considerations like
               | ecosystems, long term support, ease to find developers,
               | prior experience, etc...
        
               | coldtea wrote:
               | Probably missed the "As long as the programmers for the
               | chosen language are available, and the libs you want are
               | there" part.
        
       | la_fayette wrote:
       | I like PHP, one issue which I face with PHP though is, that it is
       | difficult to create a self-contained docker image.
       | 
       | With node.js or java spring boot i can build an application with
       | an http endpoint and create a single docker image with all
       | included easily.
       | 
       | With php I need 2 distinct containers, e.g., nginx, php-fpm and
       | the code mounted on a volume to the the containers. So it seems
       | to be more difficult for setup and continous integration etc.
       | 
       | I would like to have one image with php, a webserver and the
       | code. Is there something like that for PHP?
        
         | monsieurbanana wrote:
         | You can't have nginx and php in the same container?
        
           | oaiey wrote:
           | Does not docker recommend a single process story? Nginx is
           | typically a reverse proxy in front of an application server.
        
             | monsieurbanana wrote:
             | That's just a generic recommendation though, really nothing
             | stops you from having php and nginx in the same container.
        
         | oaiey wrote:
         | Well, at least in the past you could have run apache with
         | mod_php. And the php files should also integrateable into the
         | image.
        
         | xorcist wrote:
         | PHP has had a built-in web server since version 5.
         | 
         | People use Apache or nginx because they want to, but because
         | they need to.
        
           | la_fayette wrote:
           | I think using the php built-in webserver is not an option for
           | a production setting.
        
             | watermelon0 wrote:
             | Correct. From the documentation:
             | 
             |  _Warning: This web server is designed to aid application
             | development. It may also be useful for testing purposes or
             | for application demonstrations that are run in controlled
             | environments. It is not intended to be a full-featured web
             | server. It should not be used on a public network._
        
           | charrondev wrote:
           | The built in web server is awful on its own. Forget
           | production usage, it's hard to even use for a quick bit of
           | E2E testing.
           | 
           | Unfortunately it has some really opinionated routing rules
           | with certain file extensions, preventing you from having a
           | dynamic URL with something like a .json or a .xml extension.
           | Instead it will always try to look up a static file of that
           | and serve it instead.
           | 
           | I can't find the bug tracker issue for it but it was closed
           | out with a message along the lines of "don't use the built in
           | web server for anything besides a toy".
           | 
           | Luckily there are plenty of PHP Cli based web servers now
           | that some other commenters have mentioned.
        
             | alaxapta7 wrote:
             | You can take full control over the routing using router
             | script, then none of the default rules will apply. To be
             | honest, I really dislike how many applications are wired
             | around some Apache configuration or at least assume some
             | specific hostname or path to be used for no reason. If it
             | works with the built-in webserver, then it will work just
             | as well with pretty much any SAPI.
        
           | alaxapta7 wrote:
           | The built-in web server can only process one request at a
           | time.
        
           | slim wrote:
           | the embedded server is great for dev, but useless for
           | production. for example any url that contains a dot "." is
           | considered to be a static file. so for example this path does
           | not do what it's spposed to do
           | /login.php?token=fghjjbjkkooll.rfcgg
        
         | jfoucher wrote:
         | Yes, the apache[0] image will do what you want
         | 
         | [0] https://github.com/docker-
         | library/php/blob/1c4b255f3e5ab610c...
        
         | hchinchilla wrote:
         | I use RoadRunner for that purpose. It even has some amazing
         | features you can enable as keeping the application loaded in
         | memory between requests.
         | 
         | https://roadrunner.dev/
        
         | folmar wrote:
         | I don't really know what directed you to the nginx+fpm+volumes
         | in the first place.                 FROM php:7.2-apache
         | COPY src/ /var/www/html/
         | 
         | and this is it.
        
         | KronisLV wrote:
         | What I went with was having both a web server (Apache/Nginx)
         | and PHP-FPM in the same container image, held together by
         | Supervisor: http://supervisord.org/
         | 
         | In my case, the Dockerfile looks a bit like the following:
         | # Whatever base web server image you want, Debian/Ubuntu based
         | here       FROM .../nginx       # Bloated packages for
         | installing dependencies and also Supervisor       RUN apt-get
         | update \           && apt-get -yq --no-upgrade install \
         | software-properties-common \               supervisor \
         | && apt-get clean \           && rm -rf /var/lib/apt/lists
         | /var/cache/apt/*       # Add repository for PHP 8       RUN
         | export LC_ALL="C.UTF-8" && add-apt-repository ppa:ondrej/php
         | # Then we install PHP and the Nginx integration package (we use
         | PHP-FPM)       RUN apt-get update \           && apt-get -yq
         | --no-upgrade install \               php8.2 php8.2-common
         | php8.2-cli php8.2-dev php8.2-opcache ... php8.2-fpm \
         | && apt-get clean \           && rm -rf /var/lib/apt/lists
         | /var/cache/apt/*       # We will also need Composer for
         | managing dependencies       RUN curl -sS
         | https://getcomposer.org/installer -o /tmp/composer-setup.php \
         | && php /tmp/composer-setup.php --install-dir=/usr/local/bin
         | --filename=Composer       # Create directories, clear regular
         | web server index directories       RUN mkdir -p /run/php \
         | && rm -rf /var/www/html && mkdir -p /var/www/html       # Copy
         | over config (whatever you have)       COPY
         | ./php_nginx/etc/nginx/nginx.conf /etc/nginx/nginx.conf
         | COPY ./php_nginx/var/www/html /var/www/html       COPY
         | ./php_nginx/etc/supervisord.conf /etc/supervisord.conf       #
         | Copy PHP config (whatever you have)       COPY
         | ./php_nginx/etc/php/8.2/fpm/php.ini /etc/php/8.2/fpm/php.ini
         | COPY ./php_nginx/etc/php/8.2/fpm/php-fpm.conf
         | /etc/php/8.2/fpm/php-fpm.conf       COPY
         | ./php_nginx/etc/php/8.2/fpm/pool.d/www.conf
         | /etc/php/8.2/fpm/pool.d/www.conf       # Default run script
         | COPY ./php_nginx/docker-entrypoint.sh /docker-entrypoint.sh
         | RUN chmod +x /docker-entrypoint.sh       CMD "/docker-
         | entrypoint.sh"
         | 
         | Here's the entrypoint:                 #!/bin/sh       echo
         | "Software versions..."       nginx -V && supervisord --version
         | echo "Running Supervisor..."       supervisord
         | --configuration=/etc/supervisord.conf
         | 
         | Here's a snippet of nginx.conf, how to get *.php to be executed
         | (put inside of a server block):                 location ~
         | \.php$ {           include snippets/fastcgi-php.conf;
         | fastcgi_pass 127.0.0.1:9000;       }
         | 
         | And here's the Supervisor configuration:
         | [supervisord]       nodaemon=true              [program:php-
         | fpm]         command=/usr/sbin/php-fpm8.2 -c
         | /etc/php/8.2/fpm/php-fpm.conf --nodaemonize
         | stdout_logfile=/dev/stdout         stdout_logfile_maxbytes=0
         | stderr_logfile=/dev/stderr         stderr_logfile_maxbytes=0
         | [program:nginx]         command=/usr/sbin/nginx
         | stdout_logfile=/dev/stdout         stdout_logfile_maxbytes=0
         | stderr_logfile=/dev/stderr         stderr_logfile_maxbytes=0
         | 
         | Of course, it isn't necessarily the most idiomatic way to work
         | with containers, but if you have health checks then it should
         | still be fine. With a base image a little like this, you should
         | then be able to build your own images with the code included,
         | or use a bind mount. You can probably get images that work a
         | bit like this pre-made, this is just how I do things, in case
         | you're curious about what that might look like from scratch.
         | Apache also has mod_php which would be even simpler, though
         | generally will perform worse than PHP-FPM.
         | 
         | Curiously, this is also one of the few detriments of PHP in my
         | eyes - when compared to something like Java that just spits out
         | one .jar that can be run on anything with a compatible JDK
         | version (at least with how things are done in the recent years
         | vs standalone Apache Tomcat).
        
         | liveoneggs wrote:
         | Yes- apache with mod_php. It's the most common deployment by
         | far.
        
         | 9dev wrote:
         | Don't follow any advice to use Apache as a reverse proxy, or
         | bundle php with a classic web server.
         | 
         | There are real application servers using an event loop by now,
         | most notably Roadrunner (https://roadrunner.dev), FrankenPHP
         | (https://frankenphp.dev), Laravel Octane
         | (https://laravel.com/docs/10.x/octane#introduction), Swoole
         | Bridge for Symfony (https://github.com/insidestyles/swoole-
         | bridge-bundle).
         | 
         | In general, you can do a lot with OpenSwoole or Roadrunner.
         | They are vastly superior (in a container scenario) to any other
         | suggestion in this thread!
        
         | xav0989 wrote:
         | You can also use nginx's unit docker container, which hosts
         | php's interpreter in the nginx process.
         | 
         | https://unit.nginx.org/installation/#installation-docker
        
         | Dachande663 wrote:
         | Had good success using Nginx Unit (distinct from normal nginx)
         | for this. There's a unit-php docker image that can be used.
        
       | cutler wrote:
       | Since PHP 5.3 why would you want to use PHP instead of Java when
       | you're effectively writing Poor Man's Java but without the
       | benefits of the JVM?
        
       | rob wrote:
       | I'm in my 30s and grew up with PHP since the 2000s.
       | 
       | There's still an insane amount of money to be made with WordPress
       | plugins, WordPress support, and more. That industry isn't dead,
       | it's thriving, it's insanely cheap to jump into and not get
       | yourself into debt, and there's tons of people that need help.
       | 
       | While people here argue about the 10th "correct" way to do
       | server-side rendering (hey, React says we gotta use RSC now!) or
       | figure out how to get their Rust code to compile to WASM for
       | their Codepen demo website to increase a number from 1 to 2,
       | thousands of us churn away daily making money from this
       | "dinosaur" PHP in the real world.
       | 
       | The bias on HN makes you think PHP is completely dead and it's
       | funny to see the comments here.
        
         | gardenhedge wrote:
         | where do you find work like this?
        
         | harlanji wrote:
         | I'd be more than happy to jump back to PHP and do some
         | WordPress dev for as little as $15/hr. I feel like the problem
         | is finding the first project to get some experience and sell
         | the next project.
        
       | seydor wrote:
       | Thank god. Imagine if the whole internet was as fragile as the
       | latest opinionated twitter rockstar programmer with VC's money
        
       | zebomon wrote:
       | I learned how to code when I was a kid with a mixture of C++ my
       | dad showed me on our Dell running Windows 95 and PHP that I
       | taught myself in the years after. All through my teenage years
       | into my early 20s, anything I wanted to make I made in PHP. I
       | still have some PHP projects online, but recently when I want to
       | make anything, I set up an API in Python and build the front with
       | a JS framework.
       | 
       | Is part of this just getting in on the latest trend? Definitely.
       | I like scrolling through trending on Github, ya know?
       | 
       | But I was also just tired of writing PHP. Python is cleaner, so
       | if I can do the more complex backend stuff in that, coding is
       | more fun. I would say PHP and JS are about equally "unclean" but
       | if it's just frontend all those brackets and parentheses don't
       | become an issue as much.
       | 
       | Just one experience.
        
         | iLoveOncall wrote:
         | I'm sorry but if your only reason why PHP and JS are less
         | "clean" than Python is because they have brackets and
         | parenthesis, you're sharing your inexperience, not your
         | experience.
        
           | zebomon wrote:
           | I meant "all those brackets and parentheses" as a synecdoche.
           | I definitely don't mean my opinion to be a comment on any of
           | the actual technical benefits of JS/PHP/Python. Just
           | explaining the reason I've most recently preferred the act of
           | writing one over the other.
        
         | asddubs wrote:
         | javascript is way worse in cleanliness. PHP has the advantage
         | of having been able to break backwards compat and fix some of
         | its worst messes, even down to some questionable soft
         | equalities. Also PHP nicely sidesteps the string
         | addition/concatenation problem by having a dedicated operator
         | for concatenation.
        
           | zebomon wrote:
           | Fair enough!
        
           | kijin wrote:
           | Even better, you don't even need to worry about those
           | backward compatibility breaks if you wrote relatively clean,
           | warning-free code in the first place. Only the very worst
           | parts of PHP's legacy have been thrown out, and only after
           | multiple years of deprecation notices. They've also been
           | following semver quite strictly since 5.3, so you know
           | exactly when to expect breaking changes.
           | 
           | Compared to the Python 2 to 3 mess and the constant churn
           | that today's frontend frameworks seem to suffer from, I would
           | say that PHP is more serious about maintaining backward
           | compatibility than nearly every other language commonly used
           | in web dev.
        
         | 9dev wrote:
         | None of the cleanliness of Python will ever justify the
         | dependency management madness it brings over simply using
         | composer in PHP. It's not in the same league, not even playing
         | the same game. Give me composer and I'll get you reproducible
         | installations in CI and prod in three minutes. With Python? The
         | gurus are still discussing the best package manager after the
         | first two days.
        
           | zebomon wrote:
           | I've never used composer, so can't really comment. I'll check
           | it out sometime! Thanks for the tip.
        
       | nologic01 wrote:
       | PHP is a great web success story at so many levels. From massive
       | sites like Wikipedia that have changed the world to the long tail
       | of blogs and "Web 2" type decentralization.
       | 
       | Anecdotally I see also rude health: Wordpress already has an
       | activitypub plugin whereas symphony based kbin is a very
       | interesting proposition for a federated alternative to reddit
       | that already sees traction. And Nextcloud is delivering data
       | sovereignty and showing the way for personalized "clouds" here
       | and now.
       | 
       | What is missing from PHP is really an easily communicable
       | "story". Both at the technical level of the language and its
       | tooling and at the community level and its vision.
       | 
       | This is not unique to PHP. Older ecosystems like C++ and Java, on
       | which much of the world still runs, have a similar problem. But
       | the singular web focus of PHP means it has more of chance to
       | develop an attractive personna.
       | 
       | Its not easy but its very useful to have a very clear identity.
       | Right now the tech world goes through an ML/AI fever (and
       | associated nightmares) and a clear vision and purpose would, for
       | example make it obvious how the PHP ecosystem fits into new
       | developments and the broader client/server design.
        
       | matt3210 wrote:
       | Laravel really change the game for PHP!
        
         | eggsalada wrote:
         | [flagged]
        
         | sschueller wrote:
         | I would argue Symfony did a lot as well. Their upgrade and
         | release schedule is very good.
        
       | zyngaro wrote:
       | From php.net home page: << PHP 8.2 is a major update of the PHP
       | language.It contains many new features, including readonly
       | classes, null, false, and true as stand-alone types,... >> That
       | says all for me. Doesn't matter if it powers half the web. It's
       | an awful programming language.
        
         | smaps wrote:
         | Can you explain why you think it's an awful language? It
         | definitely used to be lacking in features, but the improvements
         | in the recent versions have been great.
        
           | zyngaro wrote:
           | Developer experience is awful. Variable names starting with
           | $, heavy object orientism that seems like an after thought,
           | tooling ecosystem is subpar, standard library is a joke, etc
           | It's a pile of crap and that's my opinion
        
             | dagw wrote:
             | I agree that the language itself has many warts and the
             | standard library is what it is, but I found the modern PHP
             | developer experience and tooling is surprisingly good. At
             | least when working within the Laravel ecosystem.
        
             | WA wrote:
             | What's wrong with the standard library? Seems pretty
             | extensive. Supports all kinds of DB drivers out of the box,
             | JSON, XML, drawing tools...
        
       | microdev wrote:
       | One thing I really dislike about PHP is the global scope and
       | imports. Introduction of namespaces is an improvement but it does
       | not change the fact that everything is in global scope. The best
       | practice for imports is to not include them outside of execution
       | context, but it also makes it very hard to reason about what is
       | actually being used by the file + you try to think about not
       | loading files unnecessarily so it's not uncommon to add the
       | import statement in the same file multiple times before using
       | something and there are no type hints that say whether the
       | include was imported or not. Which is more or less a consquence
       | of the environment not having a proper runtime and everything
       | being re-initialized with every request (in a runtime context,
       | all files that would ever by used would be included, because they
       | would be used eventually). I genuinely wonder how it came to be
       | that a language developed specifically to serve web requests is
       | not a loop, you would think that a runtime would be especially
       | useful for handling requests and Facebook learned it the hard
       | way, heck CLI input -> output programs are probably the only type
       | of program where it would not be a limitation.
        
       ___________________________________________________________________
       (page generated 2023-09-09 23:02 UTC)