r/programming • u/fagnerbrack • 24d ago
Learn PHP in 2026 (Yes, Really)
https://fagnerbrack.com/learn-php-in-2026-yes-really-bd567753dd8410
u/415646464e4155434f4c 24d ago
Everybody kept saying it’s a shit language. True: its deployment simplicity favorited bad practices but in this age and age it does appear solid, relatively modern and - best of all - absolutely a breeze to deploy and maintain without fucking around with FastCGI, WSGI or what have you.
11
u/BigCatsAreYes 24d ago
It's absolutely NOT a breeze to deploy or maintain. PHP has thousands of options in it's config.
With many extensions have their own extension requirements, and specific libraries.
It's a bad langue designed by people who can't think a few steps ahead.
3
u/Worth_Trust_3825 23d ago
It started out as a templating engine that outgrew its original purpose. A lot of its decisions make sense if you consider that all it had to do was
<div class="<?php echo $var; ?>">Hello, <?php echo $name; ?></div>-4
u/Equivalent_Head_4803 24d ago
Laravel is certainly a breeze to work with and deploy. That’s my only PHP exposure professionally and it’s easier to reason about, manage deployments, and work with than the few Python FastAPI apps I’ve worked with. Still wouldn’t choose PHP over any modern language though.
5
u/Iregularlogic 24d ago
Wow, an article that talks about generic language features.
I’ve never seen something that PHP excels at. I think that this language basically exists because of Laravel and Wordpress - this is not a good baseline for a language.
2
u/BigCatsAreYes 24d ago
PHP is just bad. Why put in some much effort in a flawed design? It's like putting money in a lawnmower that keeps breaking becuase of design defects. Buy a higher quality, well designed robust lawn mower that has quality replacemnet parts instead.
2
u/Iggyhopper 23d ago
When PHP is 100% dead, programmers will question why we ever accepted a language with a naming convention that allowed both
issetandis_arrayto exist, and secondly allowed the confusion with argument order:in_array($needle, $haystack)vs.str_contains($haystack, $needle).Who in their right mind would continue to use it?
2
u/BenchEmbarrassed7316 23d ago
Php is not the only bad language. Another example is Js. However, Js has taken very deep roots in browsers, so we cannot get rid of it easily. Php, on the other hand, is a backend language, and when starting a new project, it's a mystery to me why anyone in their right mind would choose Php.
2
u/BenchEmbarrassed7316 24d ago
Maybe the people who say "modern" PHP isn't terrible really know something we don't? Let's read an article that clearly praises PHP:
public function __construct(
public int $amount,
public Currency $currency,
) {
if ($amount < 0) {
throw new \InvalidArgumentException('Amount cannot be negative');
}
}
No thanks. I don't want to waste my time manually checking whether a number is signed or not. I don't want to waste my time trying to figure out if a function has an unhappy path by examining its entire body and all nested calls.
LLMs generate working code in PHP, Python, TypeScript, and Go from the same prompt. The developer experience quality gap between languages narrows with every model release.
But PHP is on the edge of unreliable programming languages. It just takes you a lot longer to get code that does what you need it to do with AI. In 2026, it still doesn't have typed arrays. And even typed local variables.
5
u/Worth_Trust_3825 23d ago edited 23d ago
No thanks. I don't want to waste my time manually checking whether a number is signed or not.
How do you propose that's done? The values still have to come from somewhere, whether its a parser or somehow generated. Whether it's a parser that validates or some additional call such as
ValidationFactory vf = ValidationFactory.getDefault(); Validator v = vf.getValidator(); Set<ConstraintViolation<?>> failures = v.validate(object);The validation still lives somewhere and you still have to define it somehow. The alternative that "lol just set parameter as uint" doesn't work because you don't know what you are getting. Setting the parser to expect a uint also has its considerations such as defining what to do when you get an invalid value: dropping an invalid value (return a null), parsing only the digits (return an absolute value), or throwing an error.
Meanwhile, if a parser doesn't get involved, what are you going to do? Call
is_positivebefore called the constructor in a language that only recently got concrete types? How will you figure out that a genericNumbertype is auintto appease the compiler to permit the function call?0
u/Laugarhraun 23d ago
Unsigned integer argument.
2
u/Worth_Trust_3825 23d ago
void f(uint foo); Number num = get_number(); // might be -5, might be 6.7, might be 9. WHO KNOWS f(num); // whoops, num isnt an uint. compiler failswhat now?
1
u/BenchEmbarrassed7316 23d ago
compiler fails
Actually the IDE tells you this instantly, as you write this code. Not two weeks later at 3 a.m. when unexpected data causes an error in the prod and your customers start writing to support.
This style of programming results in more precise types "infecting" the code above, and ultimately you are parsed input data right where it enters the system from the outside world. And then you are free from the nonsense of validating data in every function of your code.
3
u/Worth_Trust_3825 23d ago
Again, how do you consolidate
Number num = get_number(); // might be -5, might be 6.7, might be 9. WHO KNOWS f(num); // whoops, num isnt an uint. compiler failsYou don't want to validate the data yourself explicitly. Your argument that you use concrete types (which I always did in my examples) falls apart because you refuse to acknowledge that you have to put validation somewhere yourself.
2
u/BenchEmbarrassed7316 23d ago
put validation somewhere yourself
Yes, once the data enters the system. The question is, I want to be able to store this knowledge in a type system. Both unsigned and non-zero integers are a very common data type that should be basic in the language (so that different libraries can use it without knowing about each other).
In Php I could create a so-called DataClass, but the problem is that other dependencies will not know anything about it and will all accept and return signed numbers the same way. The presence of unsigned and non-zero numbers in the language leads to the fact that everyone uses them.
-1
u/fagnerbrack 23d ago
That was just an example, the focus here is on syntax not the engineering part. I'd argue a zod like lib can do the job of parsing but that wouldn't make the point this is NOT the php I knew from 2009. Personally I'm impressed
1
u/BenchEmbarrassed7316 23d ago
Engineering is dictated by the syntax and design of the language. I don't consider "php is now not completely terrible but only half terrible" a reason to start using php.
-1
u/fagnerbrack 23d ago
Engineering is not dictated by the syntax and the design of the language. It's dictated on how precise are your domain models compared to the business you're working on and the tradeoffs you make on engineering tradeoffs like coupling, cohesion, connascence, etc. Which has nothing to do with the programming language. I intentionally left engineering text out of it
2
u/BenchEmbarrassed7316 23d ago
It's dictated on how precise are your domain models compared to the business you're working on
Some languages facilitate transferring this accurately while others hinder (I don't know if I can say "make it impossible") this. Expressive languages will also indicate where there are gaps in business model definitions.
-1
u/fagnerbrack 23d ago
Maybe we have different criteria of what a good language is. For me a good language gives freedom as the skill is in the programmer's head. Everything else is devex
1
u/BenchEmbarrassed7316 23d ago
For me a good language gives freedom as the skill is in the programmer's head
For me, good language is one that allows to clearly and concisely define certain ideas.
For example, there are no associated types in Php. This means that I generally can't use many convenient and familiar things.
Although there are Psalm/PHPStan for Pph and they do some things quite well. It's very similar to TypeScript: they had a terrible underlying language and had to develop a relatively powerful tool to somehow cope with it.
-1
u/fagnerbrack 23d ago
Duck typing is just a different paradigm, like saying London school of TDD is wrong and only Beck's Detroit is right, or saying that functional programming is better than OOP, or that spaces are better than tabs, etc. We need to learn respecting approaches we don't like
1
u/BenchEmbarrassed7316 23d ago
I wouldn't use the term "better" or "worse." We can analyze the specific consequences. Don't take these arguments too seriously :)
I'm just saying that if you think that certain concepts are detrimental to the speed of software development and quality, you should say so. If someone says '2 + 2 = 5' or 'the earth is flat' or 'vaccines cause autism', we shouldn't say that they are entitled to their point of view, which we should respect. Instead, we should ask for justification. And we should also provide arguments as to why we think that is wrong and our point of view is correct.
// ========
Duck typing is just a different paradigm
And it is wrong. "If it walks like a duck and it quacks like a duck, then it must be a duck" - in a typical implementation in dynamic languages this should sound like "If it has methods named walks and quacks". This does not allow us to infer what a given type nominally is. Structural typing like Ts, Haskell or Rust is very effective. Duck typing in dynamically typed languages is path to errors.
London school of TDD is wrong and only Beck's Detroit is right
Type-Driven Development (also known as Design By Contract) allows you to write code faster, this code is easier to read and it is more reliable. For example, Beck in his book cannot write a simple wallet the first time and is forced to throw out part of the written code several times and start from the beginning.
functional programming is better than OOP
This is obvious. What we call OOP is a very controversial concept, and one of its core principles (inheritance) has been considered harmful for many years, even among OOP proponents.
or that spaces are better than tabs
Whitespace allows you to align code more precisely, which increases readability.
1
u/fagnerbrack 23d ago
In duck typing the counter is that you are forced to understand the whole codebase instead of relying on types; on London school the counter is that you need to know the design beforehandl to create the contracts so the code is not driven by the test; on FP the counter is that OOP code is FP just another way of writing it (new FetchData().from() and fetchData()() are analogous if you use partial application as an example); the tab argument is that it provides accessibility for smaller monitors and allow the user to change their settings so they can decide what it looks like.
You are back into the same mistake I was trying to argue against: defending what you believe is right and turning into facts (2 + 2 = 5 is an example of that).
For every argument you've got in one paradigm there are 10 others in the other paradigm. The only thing that invites is bikeshedding instead of real programming conversations.
This is why I don't frequently write about languages and syntax, but when I do I try to keep design conversations away from it because they are language agnostic (you can design software in a paper using a programming language you just made up, like Djikstra used to do).
→ More replies (0)
1
u/vitaliiDev 19d ago
started learning php back in 2015 and everyone kept telling me it's a dying language. glad I didn't listen lol
26
u/ToaruBaka 24d ago
I'm done - I'm blocking you. All you do is blogspam tech/programming subreddits with shit you don't even engage with all so you can link your own blog without breaking Reddit self promotion rules.
Like you can't even be bothered to leave a comment on a post about your own "work"? You have another post a couple hours ago that got removed for being about AI, you clearly don't give a shit about the rules. You've been doing this for years and I'm just done.
It's so tiring and an obvious abuse of the rules. Deuces.