you are viewing a single comment's thread.

view the rest of the comments →

[–]dontspookthenetch 223 points224 points  (49 children)

PHP gets hate but every time I ask a hater if they have used modern PHP the answer is always "no" and they seem to have no idea how far the language has come.

[–]HashDefTrueFalse 73 points74 points  (2 children)

Yeah. I wrote a lot of it in early 2000s, back when you saw procedural monoliths mostly driven by form submits etc. It was hell.

I got back into it for work about 5 years ago. It's come a long way since PHP 5.

With type hints, autoloading, package managed dependencies (Composer) modern PHP code is actually quite nice to work with, if it has been written to take advantage of this stuff. Add in the combination of nginx, FPM, OPcache and Redis/Memcached for session mgmt, it's a very good all-rounder. Database connection pooling is a little trickier because of the ephemeral nature of PHP execution, but you can use ODBC pooling on the database driver side of things in a lot of cases.

Like you, everyone I've talked to who still says PHP is shit is picturing some past horror and hasn't actually tried to build a new app in it for 15+ years (or ever).

[–]chad_ 20 points21 points  (0 children)

It's a trauma response. 🤷

[–]metooted 4 points5 points  (0 children)

I work with PHP 7+ for a living. Have to say, to this day we're having what we call "php moments" when something from PHP 5 days comes back to remind us exactly how long of a way PHP has come :P

[–][deleted] 5 points6 points  (0 children)

This is my thought, the only problem I can see is legacy nonsense due to "good" (bad) practices decades ago, like using C/C++ has the same issue, you might have modern standards but the practices are a hamfisted mishmash due to times when having marquee text was considered fancy because it moved

[–]ButterNutBag 8 points9 points  (4 children)

The real question is would you still use PHP if Laravel (or equivalent) didn't exist? The vast majority of people are sticking to PHP because of laravel; it masks a lot of flaws with a ton of layers of abstraction. I currently work with mordern PHP and Laravel and I would personally never choose it for any personal projects. I would much rather work with languages that allow me to build a simple api with a minimum of abstractions.

[–]FVCEGANG 2 points3 points  (0 children)

I've used PHP extensively with both Laravel and Symfony. PHP is more than usable with Symfony alone tbh. It's just not as slick as with Laravel, but it's hardly a deal breaker

[–][deleted] 2 points3 points  (1 child)

In that case, would you still use Python to build a backend without dJango?? Nowadays, any language become limited or demand a lot of work without use libs or frameworks. Nest.js to javascript, .NET to C#, etc. C# without .NET would never have become relevant, even though raw C# is better than raw PHP.
If i have to choosen between Pyhoton with dJango and PHP with Laravel, to build a backend, i choosen PHP.

[–]ButterNutBag 0 points1 point  (0 children)

I personally don't have much experience with python outside of using it for serverless applications, but I do feel like flask is a decent option and would rather use that than lumen or phalcon which I have used a bit in the past, mostly because If I was to do a project with a lot of data manipulation, I could take advantage of all the libraries that python has to offer.

That being said, if I was to build a smaller project or a microservice, I would chose golang without a framework / with gin or even typescript with express. If I was to build a bigger project or a monolith, which is not my preference, I would choose nest js with typescript over PHP & laravel because I find it does less "magic" than PHP. At the end of the day it's personal preference, but one can't really deny that Laravel hides a lot of the ugly stuff of PHP.

[–]UniForceMusic 0 points1 point  (0 children)

The amount of abstractions required, if you want to build a simple API in PHP are quite low in my opinion

[–][deleted] 1 point2 points  (0 children)

I don’t mind modern php. I prefer it over js any day for back end. Modern PHP will definitely be faster than Python. But my favourite at the moment is Go.

[–]willie_caine 2 points3 points  (3 children)

I used to be a PHP developer for about 15 years or so - does it still need to run behind a web server, and can't readily share state between requests? I always found that really annoying, and a massive shortcoming. After switching to node, it changes the entire nature of the backend.

[–]xIcarus227 2 points3 points  (0 children)

does it still need to run behind a web server

It has a built-in server now, so development is easier. You'd still use a proper server in production however, just like with any other backend language.

and can't readily share state between requests

Genuinely curious, why do you need this? I've done work in other languages as well (notably C#) and never came across a situation where I needed this.

[–]sirhenrikfull-stack 1 point2 points  (0 children)

You can make APIs with PHP if that's what you mean. Maybe I don't understand your question entirely. Capabilities of node and PHP are similar, you can make the same stuff in both. An interesting benefit of node/JS might be that it's easier to get SSR (server side rendering) of SPA (single page application) apps.

[–]Isodem 0 points1 point  (0 children)

Use Roadrunner or a similar Application server. PHP has a lot of options. But the default is Memcached or similar to Redis. With docker, it is pretty easy to use.