Live data from Hacker News

PHP in 2023

stitcher.io

221–230 of 285 posts

Re: PHP in 2023

#221

Earlier quoted context omitted.

Uhm, how about PHP attributes, getting rid of comments / annotations? Named arguments? Constructor property promotion? Readonly properties (8.1) / classes (8.2)? Arrow functions or typed properties (both 7.4)? I'd say those are really cool things. Especially as a web developer, there's just so much boilerplate I can get rid of since using 8.0+.

I’m in agreement with you that it came a very long way. Now, most of those have been present in many other languages [0], often with less limitations. And as usual the old ways haven’t all been deprecated either, so it stays weird. For instance typed properties were a chance to reset the clock on type handling, but no, declaring a type will force cast parameters to that type instead of throwing an error (i.e. passing…

> declaring a type will force cast parameters to that type instead of throwing an error

There is `declare(strict_types=1)`[0]

[0]: https://www.php.net/manual/en/language.types.declarations.ph...

Re: PHP in 2023

#223
post #167

Earlier quoted context omitted.

> The way we make webpages is so disconnected from the technologies that browsers offer us. Can you say more about this? I don't really see how "actual applications" differ from a React app in a meaningful way; React apps almost always leverage the capabilities of of course HTML/CSS/JS, history, AJAX/HTTP, cookies, and so on. As the JS distributions evolve, the build systems do too in terms of output. Maybe I misunde…

> Can you say more about this? I don't really see how "actual applications" differ from a React app in a meaningful way; React is everything the web (in its initial conception) was never meant to be. HTML was meant to be used for static documents. CSS (single file, linked to by all documents) was meant to add styling to all those documents. JS was meant to add simple interactivity to documents. Navigating between doc…

Sometimes the best platform is the one you have though. It’s not conceptually good, but its ubiquity is good. Slowly we creep towards HTML/CSS/JS as solely a compile target haha.

Also, just because of tone-death in text, I’ll say I agree with you! The web as an application platform is a bodge. Humanity loves bodging though!

Re: PHP in 2023

#224
post #103

What really struck me was the statement: "In total, $580,000 was raised in 2022 The Foundation pays 6 developers to work on PHP" which made me realise how easy it is to take for granted the development and maintenance of these open-source languages and ecosystem as a whole. Say what you will about PHP, but we all rest on the shoulders of the incalculable effort that goes into the software we use everyday without thin…

Similarly, cURL has been maintained by Daniel Stenberg for nearly 30 years. Billions of installs, every major tech company probably uses it... labor of love.

Re: PHP in 2023

#225

Earlier quoted context omitted.

You can look at a Laravel (Eloquent) model and easily see what methods it has. Nothing is hidden -- at least no more than any ORM that inherits from another class which gives it functionality. As for properties -- yes, they're not explicitly described but mapped to the database schema. Other ORMs, like that in Ruby on Rails, also do not explicitly set model properties and just map to database columns. People have bee…

> Symfony is a great piece of software. So is Laravel. And to be clear, Laravel is a piece of Symfony software , and a good example of what you can do with Symfony packages and a bit of opinion. There are 13 Symfony dependencies in https://github.com/laravel/framework/blob/9.x/composer.json alone, and many of the Laravel packages listed in there also depend on them; the Laravel Request class extends Symfony\Component…

It's a lot more than "a bit of opinion". It's a huge framework with tons of unique and original features. You're being very reductive. Yes it does use Symfony components for some core functionality, but that's just a small part of what Laravel offers.

Re: PHP in 2023

#226

Earlier quoted context omitted.

> Symfony is a great piece of software. So is Laravel. And to be clear, Laravel is a piece of Symfony software , and a good example of what you can do with Symfony packages and a bit of opinion. There are 13 Symfony dependencies in https://github.com/laravel/framework/blob/9.x/composer.json alone, and many of the Laravel packages listed in there also depend on them; the Laravel Request class extends Symfony\Component…

It's a lot more than "a bit of opinion". It's a huge framework with tons of unique and original features. You're being very reductive. Yes it does use Symfony components for some core functionality, but that's just a small part of what Laravel offers.

I think we largely agree; I just think "Laravel or Symfony" is somewhat a false dilemma because of this. You can build your own system on Symfony libraries... or you can use Laravel's system that's heavily built on Symfony libraries, with a lot of the plumbing done for you.

Re: PHP in 2023

#227
post #205

Earlier quoted context omitted.

A "React vs PHP" Google search turns up tons of articles and forum questions with that exact same comparison. So either it's logical to compare the two, or the internet is just full of idiots like me and the parent poster :D.

Many of those questions have answers that point out you are comparing two very different things. Some of them are explicitly comparing Laravel and React, which makes a bit more sense. The rest seem to be AI generated trash. The easiest way to explain it is that you could reasonably use react within a PHP project. I wouldn't use the term "idiot" but rather "ignorant". A good article that answers the PHP vs React quest…

For reference, I'm working with both React and PHP. And yes, for example WordPress uses React components. I'm a 42 year old software architect. But hey, maybe I've been ignorant all this time.

React vs PHP is a decision you can make, because... the intention of both is to output HTML.

edit:

> The easiest way to explain it is that you could reasonably use react within a PHP project.

I can use C within a Python project. Does that mean I can't compare the two? One is compiled while the other is interpreted, so maybe you can't compare those?

Re: PHP in 2023

#228
post #150

Earlier quoted context omitted.

How so? Nextjs only offers ssr and routing. Nothing else. Not even close to the full stack functionality you find in a default laravel or rails project.

It also has API routes and Middleware. But yeah, Laravel includes more by default. With Next.js, you need to pick a few more tools to go along with your stack. E.g. Next.js, NextAuth, Prisma, SQL database. You end up in a similar place, it's just not all part of the same package. That may or may not be beneficial for your team.

And the advantage of Next is that you can leverage React components server side and client side, and share code between them.

Laravel Livewire is pretty nice for basic interactivity, which is all many sites need, but React becomes useful as soon as you start needing app-like features. At that point, using Next, which is already plugged in to that ecosystem, is a very nice experience.

Next is great for static sites, too, so nowadays I prefer putting my time into that vs. fragmenting between a more purely server-side framework like Laravel.

Re: PHP in 2023

#229

Earlier quoted context omitted.

Just to offer an alternate opinion for anyone reading -- check out Next.js

Next.js is great but can't compare to Laravel, they are not for the same use case. Laravel comes with an ORM, a job queue, a mail framework... And it can also scaffold a complete auth system for you

You can just add Bull/Temporal, Prisma/Knex and Braze and you can swap stuff when needed but I understand that for new people it's nice to have everything integrated when starting out.

Still seems like most people write separate backend and Nest.js is most popular. I am not a biggest fan yet personally.

Re: PHP in 2023

#230
post #67
post #21

Earlier quoted context omitted.

How has PHP lost its way? It grew up from a poorly thought out hacky scripting language to a major programming language. All the nasty code you could write in PHP 4 or 5 is still possible, but everyone will look at your code and laugh.

Maybe because there are already major programming languages at that level already, which arguably do things better: if you are going to have a Java-like OO model, then just use Java (and leverage its ecosystem, tooling etc). Whereas there is a niche for a quick-and-dirty scripting language for just getting something up and running.

If you honestly think Java is the solution to replace PHP you clearly know very little about the language and its usage.
Post reply on HN