Hacker News new | past | comments | ask | show | jobs | submit login

I am genuinely interested why anyone would start a new project in PHP currently. What are the reasons?



The real question would be why not ?

Many of the quirks and problematic parts have been addressed through the years, it's battle tested, and there is a healthy and stable ecosystem behind. It doesn't need to be everyone's first choice, but there's also no strong reason to avoid using it in its current state.


Because it's good enough for almost everything. The vast majority of projects will never have to scale to billions of users, so hyperscalability is not a huge concern.

It has a low barrier to entry and great language features - static typing being one of the big ones. It has become a really nice language over the years, great to work in and in no way less satisfying or effective than for example golang.

And, of course, laravel exists.


> The vast majority of projects will never have to scale to billions of users, so hyperscalability is not a huge concern.

I would have thought PHP would scale very well. It may not be high performance, but its start each request-response cycle from scratch should scale horizontally very well, surely?


It does. But scaling to billions of users (or billions of requests per day) is still not easy and you really need high performance for that. Laravel scales to a certain point, where their design decisions (eloquent, the queuing system etc.) are still working.

That said, with today's PHP it is possible to optimize the hot path pretty well with stuff like FFI.


Correct, the real bottleneck is almost always the database.


> It has a low barrier to entry and great language features - static typing being one of the big ones

... and it's completely optional in many cases on top of that. Even if you're using third party libraries, it will only crash if you mess up your types at the library's interface.


I worked at a company that had half C#, half PHP developers. The PHP developers ran circles around them both in building features, and in fixing vulnerabilities (I was hired for a reason, legacy code). I can always depend on a PHP developer to outrun anyone else.


By the time a large C# solution finishes compiling, the PHP Dev already started another ticket and is pressing F5 to insta check if his code works so he can move to the third ticket of the day.


This hurts because it’s true and sometimes I’m jealous of the build kids who get to work on tiny features all day while I’m switching back and forth with a browser. I know native has its own challenges (looking at Apple here with the imminent redesign that will stop all product teams in their tracks) but it still doesn’t mean I’m not jealous sometimes


PHP is better than any of its alternatives within its problem space.


It's cheap, it's fast, it's simple, and it works everywhere.


It just works out of the box, and request-response model still fits the web better than any other solution out there.

And it's still performant enough https://x.com/arvidkahl/status/1775261978006896730


Especially if you use FrankenPHP!


If all the other reasons given here don't convince you already, I have one more to offer: Match Expressions[1]!

[1]: https://php.watch/versions/8.0/match-expression


That's a great one. On of the things I really enjoy when using Rust.

https://doc.rust-lang.org/reference/expressions/match-expr.h...


Laravel. My previous employer was using it for casino/sportsbook websites and they were able to scale so much with Laravel micro services.

(They had hundreds of millions of profit)


I would hope so considering they’re literally a casino…


TL;DR Your dad's PHP is no longer the current PHP. The language itself has been thoroughly modernized, made more consistent, bug free and performant. There is nothing better than a piece of software that keeps getting improved decade after decade borne out of real developer needs and experience.

- Type annotations are integrated and work well with PHP now. This results in a kind of scripty Java OOP that is more succinct and type checked ! (it is possible to write PHP without types when you want metaprogramming features also)

- Many inconsistencies in the design of the language (OOP, function naming etc.) have been resolved/smoothed out

- The language recognises the inherent problems with `null` and allows you to make type annotations that rule out null. This is my smell test for a language BTW -- golang for instance does not seem to have a good story for null.

- PHP Language developers have been really good about increasing performance year after year

- Lots of software like web frameworks and CMSes continue to be based on PHP

And -- the greatest part of the design -- PHP remains the best example of the "shared nothing" architecture. An architecture that allows you to scale your application easily.


> Your dad's PHP is no longer the current PHP.

I am pretty much in the "your dad" category here. Where best to start learning how PHP has changed since I used it?

There are things that appeal to be about PHP.


Build something with symfony or laravel. In this space PHP is used in the modern way. Don't look at WordPress, Pimcore, WooCommerce et al. They're pretty much stuck with old PHP.

That said, you can still shoot yourself in the foot with PHP. The dark alleys are all still there.


Thanks. I never want to look at WP again so that suits me :)

I looked at Symfony a few years back and it looked nice. if it has kept up with modern PHP it looks like a nice choice.


I would say that symfony is the base of modern PHP. Laravel and others can only be as beautiful as symfony is.


It just works and has batteries included.


Yep, nuclear batteries. Laravel and the whole PHP ecosystem is just so much ahead of any other programming language when it comes to building websites and APIs it's insane.


in a world where many projects are started with Python and Ruby, PHP has definitely a bright spot.


The language has its quirks, but frameworks like Laravel make application / API development very easy. And, of course, it runs practically anywhere :)


As mentioned by others, PHP today is not the PHP that is still in most peoples heads. For me one of the big advantages is ease of deployment. No docker, no images, no overhead, scp it to any toaster running apache and you are done!


But how do you install dependencies? Is the "it" you're scping a folder structure that includes them?


Dependencies are managed by Composer (like npm, cargo, etc) for more than 10 years now.

https://getcomposer.org


I was replying to the previous comment - how does this relate to that?


You asked how you install dependencies, they answered that question.


Because I‘m good in it. And my clients don‘t depend on me - they can choose to continue working with me not because I‘m the only one who knows how the language works, but because they WANT to.


I legit started a new customer project (simple business website) on PHP a cple days ago:

The reason is simple: It's to me the most efficient, best performant SSR option out there, if your requirements are simple.

You will be amazed at the website's speed. We are so used to the lethargic JS slop of the average website out there these days.

I love PHP, I believe future "vibe coders" will be left bedazzled at its powers, which will be beyond their comprehension.


Did you use any plain PHP or any framework?


plain in this case (would use a framework if i needed db, and perhaps auth)


it's pretty nice now, you don't even need a framework


While this is true, I would say that your advice only applies if you have experience with other web frameworks from other languages. If you’re coming at it blind to any sort of web development, the features afforded to you by a web framework are really useful and helpful to understand.

For example, imagine someone who had never really thought about routing in a definitions file versus file based versus annotations. Three valid use cases that might not exist if if you have a background in something like hardware or if you come from a non-programming discipline.

If you do have that experience, you can rebuild almost any affordance in PHP at this point and it purely comes down to personal preference and how you like to write and design with code.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: