PHP has garnered a bad reputation in the software market. Many developers hold strong opinions against the language and to some extent, that's corr...
For further actions, you may consider blocking this person and/or reporting abuse
Great summary. I still use PHP. In fact, our API is running on PHP Slim 3 framework. PSR, Autoloading, Composer - all great improvements to the PHP community. My biggest complaint historically has been inconsistent argument order across similar methods, Strings in particular.
I also love that PHP is open-ended. There's more than one way to skin a cat.
I like that I can run PHP on any web server of my choosing - let's say Apache running on Event MPM, or nginx.
Right, inconsistency has been a major issue with PHP and it needs to be addressed. It sometimes gets annoying.
But again, remembering every argument order would be hard in any language. The manual or a nice IDE/Text editor should make up for it. PHPStorm does a really good job.
The oft-cited issue of $needle & $haystack order is moot. It's one way for array functions & one way for string functions. != inconsistent.
need and haystack are used for search functions. The very thinking in 'array' or 'string' functions as PHP has it is just proof of the madness baked in the language. We are talking search functions that happen to apply to arrays or strings. If there's a good reason for them to be that way, I'd love to hear it.
So you're saying the functions should overload their purpose & accept both string or array haystacks?
PHP is the best language out there. Whoever says otherwise is just crazy or just doesn't have enough imagination. You can literally do anything you can think of with it.
What the? I'm curious, what make you feel so strongly? There are a ton of fantastic lower and higher level languages to try, does it interest you to try something else. You might find the experience helps your writing better code in general.
But of course i'm going to use other languages as well. And it does help in writing better code knowing other languages but I've used many languages both in web and game development (C++, obj C, java) and even various js frameworks like vue, nodejs etc but for some reason i always end up using php either as a backend or for logic and data manipulation and db interaction. Why? Because it is way faster, cleaner and easier to do all that compared to the rest. Try handling db queries with Vue, java or Obj C...and i am not talking about simple Selects here, but creating db queries based on user entries where you have tons of if/else/cases before deciding the ending query. I was working on a big project with a search form that had 50+ fields, combining 20+ tables, and 2 databases to bring back results. How are you going to handle all those cases if not with PHP? How many days would it take you to write that code using any other language?
Let me give you another example. My phone company gives me about 300min of mobile calls free of charge per month. It has no way of notifying me when i go over the limit (and why would they), so i had to think of an easy way of doing that myself. I wrote a parser that logs in my web account, checks my balance, uploads the stats in a db for a graph i made, then decides whether to notify me if i am approaching my limit etc via sms, email or push notification depending if my phone is under the same network or not. This thing uses crons, bash scripts, mysql, and also provides a GUI for various tweaks like check intervals the graph etc, all controlled via php. How long is the code? about 100 lines of code, done in a few hours. How would do all the above if not with PHP? How long would it take you, and how many different languages would you use?
You want another example ? There was a project that had a huge db of addresses that were stored in textareas (entries from an old system) and needed to have them separately each part in a different column, like zip code, address, area, country etc. There are some libraries out there that can do that, but you'd have to load an .so or .dll on the server first and that was not doable at the time. I wrote a parser that would break down a db entry into parts then try to figure out which is which using A.I algorithms to predict what is a street address, what is a zip code etc, and if it couldnt find or it wasnt sure about something, it would google it and then from the page results it will figure out if it's a city, a village, a country, a zip code, a phone number....whatever...and then act accordingly....yes..using PHP and it had 100% success at separating any entry you threw at it. I am sorry but how would you solve this problem using any other language?
I am not a PHP hater, I am not a hater period. I don't know if I agree, because subjectivity, I feel that Rust is the best language out there... For specific reasons. PHP is probably the best server language for PHP based servers. As for your numerous examples. I don't understand really why a language like rust with a decent package manager could not achieve what you have described. You have listed so much it's hard to answer. But I could say this, where there's a package manager there's probably a solution in ANY language. I'm glad you like PHP but keep an open mind, PHP is not forever 😅
That doesn't mean anything and is incorrect. Sure, it is Turing complete but so is every programming language that is widely used. That says nothing about its power, features or sanity.
There are intractable problems that can not be solved mathematically(thus can not be done using a programming language - programming is math, this is a fundamental misundering amateurs such as all PHP programmers fail to grasp) therefore PHP can not do everything. No language can.
Still waiting for the well-educated PHP fan...
Of course you are not going to be able to write an A.I program. No language can. All they can do is imitate intelligence by predicting stuff. But i dare you to try and do all that with any other framework you can think of without using PHP at least as an ajax receiver for DB querying efficiently and above all fast enough to do it all in one sitting.
All i am saying is, any idea that i had i was able to visualize and implement it with PHP much faster and more efficiently than any other language out there.
I've written custom web applications, web-to-game server interactions using sockets and db queries, very 'intelligent' parsers of all kinds, prediction algorithms, home automation scripts, obfuscators...you name it. The list goes on and on. PHP is used by 78.9% of all websites out there. You can easily hook up html, js, sockets or anything else you want into it really fast and test things out in a matter of seconds...when everyone else is still compiling.
You said "You can literally do anything you can think of with it." That is so wrong it is simply disproven and so shocking that only a PHP fan would write that.
Actually, AI is not on the list of intractable problems, if it were there would not be billions of dollars being dumped into it.
A basic and simple intractable problem is the Halting Problem, even a PHP fan might be able to understand that one.
That stat is flat-out wrong. Those stats will count a server that might have mod-php installed even if PHP is not running anything on it. Even if your laughable stats were correct, it would not prove anything other than there are a lot of morons out there, thankfully your stats are wrong.
I bet you consider Facebook to be a "PHP site" when all it is used for is template generation, none of the heavy work is done with it. Languages professionally designed(PHP is not designed in any manner whatsoever) languages is what runs the important backend stuff.
Using PHP has cost FB tens of millions of dollars and set them back years, that is probably a good thing since they are such a danger to the world.
PHP doesn't run anything important on the web. Not one thing.
PHP is dog crap, there is no technical merit, not even its fanboys can name anything technical that is good about.
Too bad PHP development can not even imitate intelligence.
This whole thread is crazzy 🤣.
That people keep referring to the 'Fractal of bad Design' article which is from 2012 (!!) is tiresome.
Like 7 years of evolution doesn't deserve a new look? Sigh.
A few things are fixed, many problems added to that list. So the bottom line is his huge list of mind-melting problems is bigger today than in 2012.
The fact that PHP 5 is still used for new monstrosities also make the Fractal article relevant today.
So no it does not.
I fail to see how it's the fault of the language... that people & irresponsible hosting companies keep using the old versions.
It makes the article relevant.
I generally agree with the summary even though the points are not entirely consistent and it severely misses the big picture of "sucking".
Even though the strictly technical criticism of the cited article no longer applies to newer PHP, PHP as a language and ecosystem sucks a lot largely due to its maintainers but also the community.
PHP 5 had several problems that are at the root of that:
You offer some advice for PHP5 users and you also mention using strict types. Do you know that strict types are a PHP7 thing, right? You're basically telling people to upgrade, which comes with a learning curve, particularly for OOP practices. It's a costly upgrade and factor in that of all PHP applications in the wild almost 60% use version 5, people's opinion of PHP will stick to version 5. No wonder people still refer to that article!!
Also .... you tell people to follow PHP-FIG. Do you mean all standards? (that would be nice) or you just mean coding standards (aka PSR-2 - which incidentally was deprecated, but people still follow it and quote it out of inertia). I'm asking because one of the most famous frameworks (Symfony) isn't compatible with the most needed standards: PSR7 and PSR15. It's mind-blowing that incredibly useful components like HttpFoundation (I love working with their requests and responses) don't provide builders for PSR7 and PSR15. Yeah, they provide a bridge as a separate package which only adds to boilerplate.
Speaking of composer, I wouldn't be so eager to jump into packages. My usual tooling for APIs involves PHPDI's container, theleague's router and stuff like Monolog and Doctrine but that's about it. A recent nightmare involved mailgun and some sms sending API that each had the same dependency locked at different versions. It's a matter of time before running into version conflicts that, in the happy occasion when there's a resolution, ends up with using the lower common acceptable version (which, given the way most libraries go for compatibility, means code from PHP5 era - a great example for the developers that end up using it). In the case of node, for example, older packages aren't that problematic since even what's considered older at the moment (think node 6) isn't as old as vanilla PHP5.
And last, my personal gripe with the PHP ecosystem is that in many cases the tendency is to copy Java. Java-fication is most obvious on frameworks like the defunct Silex or Symfony. Fortunately now there are some nice alternatives (Symlex, Ubiquity) that are embracing PHP7 for what it is, instead of trying to copy another language. Add to that application engines like Roadrunner that bring true performance and nowadays we have something workable.
But there's also the tendency to get stuck in OOP world (I get it, PHP has be so slow to evolve that I've seen developers jump at OOP as if they suddenly discovered sliced bread - most OOP 'benefits' are a myth and while it did help promote great practices like SOLID, they aren't tied to OOP and apply regardless of core paradigm). Other languages offer functional programming alternatives or strong code support for it, PHP only got Swoft framework fairly recently and it's quite in its infancy.
I think you started with a great post but deviated in the middle of it.
If you step back for a second you can see the irony in the post.
You're asking people that hold strong opinions against PHP to open their minds a little and see the evolution of the language. The key component here is "strong opinion". It is the core of all these discussions.
Your article is packed with strong opinions such as "you shouldn't use a web framework", "you should use strict typing", and "active record is evil".
At the expense of trying to convince strong opinionated people that PHP dont suck you end up spreading your strong opinion against one of the largest PHP community: Laravel. A web framework without static typing build with Active Record in mind.
It makes your article read as: "Hey people, you have some pretty bad strong opinion about PHP. Here are some up to date strong opinions you should hold so that we can collectively hate on other communities instead".
My reply may seem like I have some strong strong opinions of my own and to a certain extent that is true, but what I've been learning is that it's best to keep ripping strong opinions apart and being accepting of the diversity. As an example, you could have said that with PHP you're not forced into a web framework if you dont like to be bound to one, but for those that do like it we have some great ones like Symfony, Laravel and Slim.
TL;DR: Try not to advertise against strong opinions with more strong opinions.
I understand what you mean by that. And yes, I do hold strong opinions on my own. But the fact is, I'm not forcing any of those ideas to anyone.
Strict typing is optional, as I mentioned in the post, in a dynamically typed language of course you'd like to use the dynamic typing. What I wanted to convey is: use dynamic typing when you need to, otherwise stay on the safer side with predictability.
Also, I am not targeting any particular framework. Laravel has its problems and so does every other framework. Choose what you need to, when you need to. I personally like taking pieces off Symfony and wiring them up together. I never said, "never use a web framework". I recommended to not get tightly coupled to one framework.
About Active Record: yes, I do believe it's an Anti-pattern. And I would advise anyone against it.
Not all programming languages suck. If someone is not comfortable with the headaches of programming, it's not that programming sucks.
I can for sure say PHP programming is more joyful than many of others.
Most of the times I see someone blames PHP, s/he is less familiar with PHP and in fact, is angry of why PHP makes more sense than the language s/he code in.
I use it from times to times. It's just a good programming lang for me...
Thanks for sharing the links that you did. I got to read the amazing "PHP: a fractal of bad design" and saw the people who build PHP itself. I am a MERN stack developer and I started to explore PHP and WordPress theme development.
Ooh boy, the ecosystem, design principle in PHP and WordPress are just so bad! They are extremely bad. I'm not saying this because I have anything against PHP, I willingly came to learn it with an open mind and I will keep studying it.
But as a PHP developer now, I must say, PHP is a badly designed language and things like WordPress complement bad design further.
Putting people on blast for making a blanket put down on PHP while doing the exact same thing to JavaScript deflates your points.
I am not entirely against Javascript. I use Javascript because I need to, not a fan of how it does things but I need it.
It's a thing that grew out of experience, as I mentioned - some people tried to shove it down my throat by talking of its superiority over everything else. Then I realized what the community is doing.
Every year a new cool Javascript framework/library comes out, and everyone - especially the newbies run towards them while making it a big fuss about it and try to push everyone to that as well.
Node is super fast, use it everywhere!
I don't see that happening at the PHP community, or anywhere else to be honest.
PHP is meant for the web, and it only does web and does it well. Javascript on the other hand... browser -> server -> desktop apps... I just hope it doesn't end up in embedded systems.
Well, that last bit is not true. You can use PHP for more than just Web.
As for the other part, well, you can call them noobies if it makes you feel better, but for someone who has been doing this for more than 20 years, all developers who complain about one framework or the other look like noobs. All frameworks have their pros and cons, and the best point made in your post is that the cons almost always come from people who don't know what they are doing, but that point hurts you when you start complaining about Node because well... do the math.
Again, I'm not complaining about Node. I'm complaining about the people who constantly keep pushing Node to others.
The difference lies in the fact that I'm not trying to force my opinion on anyone about JavaScript. People who keep pushing JS everywhere do.
I believe JS does fine for client side, that's what it was meant for. But the community started trying to bring it to everything else too. And the newcomers somehow fall into the trap of blindly following any cool new framework that comes their way and they keep pushing it everywhere.
I'm sure more experienced developers like yourself understand that languages are just tools and some tools are more fit for some things better than other.
And yes, you can use PHP for other things too. But you wouldn't do it in production in your right state of mind.
Node works fine in other areas, too. It's got plenty of things I dislike and wouldn't be my first go-to in most cases, but implying that it doesn't belong in those areas is the same backwards thinking as "PHP is trash".
My point is, you have kind of a roundabout way of putting down the other guy in the same way that you've probably been put down, and most likely, neither really deserve it.
As for that production comment, I'm going to disagree with you again. Consider if you have a framework that includes a PHP library that is the center for managing certain entity types. That functionality may include file i/o, database ops, external API integrations, etc., now consider your CI needs to perform some manipulations in certain workflows, would it be smarter to rewrite that functionality in another language or use PHP and import the library you already have?
If you complain about using a framework with Python and then happily write you use composer and that Doctrine is good then no one should take you seriously.
"Your coworkers are probably too free, maybe their code is still compiling."
You realize most Go applications are small and compile within 3 seconds, right?
Your arguments are just invalid. Active record is not evil. The thing that is evil here is Doctrine with the insane amount of abstraction which makes doing things efficiently impossible.
Doctrine is a great example of what is wrong with PHP and the people who invented it didn't help the cause. It makes it slow down to a halt with inefficient queries and cluttered classes.
Something funny I think we all forget is that there is a book out there famously titled "Javascript: The Good Parts". Where we all poo poo'd on javascript for being a bad language because we all implemented bad patterns and didn't fully understand prototypical inheritance. Back then we were throwing the term Javascript Sucks.
I do hope that we remove this idea that "PHP Sucks" because it really doesn't.
What you are forgetting, or simply do not realize is that the point of the book was to point people away from the bad parts, which never have to be used. There is a powerful and sane subset of JS.
No such subset in PHP. The poorly thought-out and mind-melting idiocy weaves throughout the language. It is impossible to write "PHP: The Good Parts" and still have a complete and useful language.
That PHP end users don't understand this, or understand CS concepts in general, is an indictment on the entire PHP ecosystem.
It is not just your comment, every pro-PHP comment lacks any technical sophistication or understanding. That is PHP in a nutshell.
PHP: for amateurs, by amateurs.
That every language has problems does not mean that the problems in languages are equivalent to each other or have the same number or severity of them.
Most problems in sane languages are either something small that was overlooked or is a consequence of having to make tradeoffs. The vast majority of PHP's problems are from pure ignorance and lack of any design. It doesn't even rise to the level of poor design because that implies that there is a design to it.
PHP language and community is a mirror that JS look into in order to avoid the same fate of being a joke.
I would suggest checking out Laravel as a fantastic way to help write great code in PHP.
Laravel has its downsides with Eloquent being a god class with a lot of hidden magic. Active Record as I mentioned in the post is considered an anti-pattern by many.
And personally, I'm not a fan of Laravel facades.
still in the process moving my code from php to nodejs..., I am lazy and prefer to do everything in 1 language
removed
Nice article. I’ve seen and, to be honest, written some pretty bad php code in my time, but learning OOP through using the Laravel framework really helped me up my game.
PHP is fine. Everyone should use composer and PHP-FIG.
Then why aren't composer and PHP-FIG part of PHP?
PHP is fine.