Live data from Hacker News

Go with PHP

gowithphp.com

291–300 of 532 posts

Re: Go with PHP

#291

I see couple singletons calls in those examples. Is it considered a good practice in PHP now, or was it made to simplify the demoed code?

Maybe you mean 'static' calls?

Depends on the context but in most cases these are a convenience, syntactic sugar.

Take SendOrderToVendor::dispatch($order)->onQueue('orders'), for example.

This could also be written as:

$job = new SendOrderToVendor($order);

$job->dispatchOn('orders');

(Exact function calls may not be correct, I'm on my phone)

Functionally identical - same code path. The main gain is ergonomics, but it's entirely your choice how you prefer to write this code.

Re: Go with PHP

#292
post #253

Earlier quoted context omitted.

This 100%. It's actually a bit of a red flag to me these days if a developer turns up their nose at PHP. The language has matured a lot and building stuff with it is simple, cheap, straightforward and fast. If someone's still hating on PHP in 2023 it makes me wonder if they've been focused on more exotic technology because they were looking to pad their resume with more expensive skills, build science projects for th…

> If someone's still hating on PHP in 2023 it makes me wonder if they've been focused on more exotic technology because they were looking to pad their resume with more expensive skills, build science projects for their own amusement vs. what the business needed, etc. etc. Red flag. I get that you are arguing from personal experiences, people you met and worked with. But this statement lacks context and nuance. There…

> magic framework stuff that Laravel/Symphony provide

The magic in these frameworks is evil, and likely a big part in ruining PHP's reputation. Laravel in particular hides way too much stuff behind magic, and when it goes wrong you find yourself sifting through OOP-obfuscated layers of framework and libraries just to find out how exactly your controller is called.

Re: Go with PHP

#294
post #107

Earlier quoted context omitted.

> it's a progressive back-end with long polling like NextJS I suppose It’s kind of funny that this is the new best thing, when this is almost the same model JSF did decades ago.

It just had so many other issues with its ergonomics that this nice innovation was lost in the weeds a bit.

That I agree with, though I found that for internal admin pages with many forms, there was nothing more productive.

Re: Go with PHP

#295
I too was a junior that was plagued by wordpress and php custom plugins, never again will I touch this language if I can.

Re: Go with PHP

#296
post #66

Why would you go with PHP+whateverframework instead of Ruby on Rails or Django? I haven't touched PHP since 5th version and I'm kind of sceptical it can offer anything RoR can't.

Use the right tool for the right job. I always use plain PHP for all those things I want to keep running forever without having to spend time and brain space to maintain. You can't beat putting a file on a LAMP server and forget it's running. I have tons of public endpoint that do all sort of stuff , aren't core to my business and don't want to deal with the operation hassle that would come to keep such framework working and running in the long run.

Just a few examples of such PHP script:

1. an endpoint that is being called by my CI to send messages on IRC and telegram when a new build is ready

2. the analytics bit of my project so I know who does what without relying on google analytics but by storing all that stuff in a mysql db. It's under 25 lines of PHP code and has worked a lot better for me than any analytics tools I've tried: https://gist.githubusercontent.com/mickael-kerjean/289d3d0be...

3. the target of the contact me form of my project

4. all the webhooks and other simple marketing automation stuff I need to process one way or another

5. all sort of online tools relevant to my niche to boost the SEO side of my OSS project

6. my status page which is an array of url I look after that is being curl around

7. crud cloud instance of my OSS project

and many many more examples, got about a hundred random stuff running from a single cheapo VPS I don't have to maintain.

Re: Go with PHP

#297

I see couple singletons calls in those examples. Is it considered a good practice in PHP now, or was it made to simplify the demoed code?

Laravel calls them "Facades". And no, they're not considered good practice outside the Laravel community.

Re: Go with PHP

#298
post #294

Earlier quoted context omitted.

It just had so many other issues with its ergonomics that this nice innovation was lost in the weeds a bit.

That I agree with, though I found that for internal admin pages with many forms, there was nothing more productive.

I actually used a product that built on top of it, so my experience is probably worse than yours!

Re: Go with PHP

#299

Earlier quoted context omitted.

Encodings are a non issue in PHP and the availability of web tools is much wider in php than for python. PHP matured in the sense that it from a wordpress type of hacky language to an almost decent language. It can be used properly if you know what you are doing (ie can scale really well for the web, can be secure, allows for good oop design, can be fast _for the web_, and has a wide range of supported packages, sepa…

> and the availability of web tools is much wider in php than for python. If that was a metric for language quality, then Javascript would be undeniably the most perfect language ever designed by any intelligent species in the universe, judging by the number of frameworks. > to an almost decent language And now I would like to hear a good reason why I should use an "almost decent language", when I can use a decent on…

I am not saying that’s a metric of the language’s quality, nor am i saying that python is worse than php.

What i am saying is that the offering of tools has matured in php - instead of a basic template engine like smarty you now have “advanced” templating engines, packages and so on. Python has less packages but that can also he because python packages work better and there is no need for an overwhelming number of packages.

Regarding error handling that’s precisely one of the many issues with php. There are so many ways of doing the same thing that it becomes exhausting. And what many php devs do is they work around these issues either by endless hair splitting debates or a dubious amount of made up design patterns.

You shouldn't use php, i am totally against it. I think it’s as bad as it can affect your mental health. Just saying that by comparison to it’s previous versions it has come a long way.

However it does handle character encoding quite well and you can scale as much as you want to literally. Probably because thats too complex for the average php developer and it was left to core language developers which are pretty competent and experienced.

Re: Go with PHP

#300
The other day I finished a side gig I was doing - a Wordpress site recreated using the Wayback Machine - the site went down a while ago and the admin stopped answering phone calls, not to mention emails.

It was a largely pleasant experience, taking me back to my early years as a "web developer". I had to modify some PHP files because the theme used didn't offer slots for widgets in places I wanted it to.

That being said uncached the site takes over 20 seconds to render. CPU load wasn't high so I can't help but wonder what was it doing all this time.

Post reply on HN