September 6th, 2024

PHP is the new JavaScript?

PHP is regaining popularity, primarily due to the Laravel framework, which enhances its development experience with structured features, shifting perceptions in the developer community towards its viability for modern applications.

Read original articleLink Icon
PHP is the new JavaScript?

The article discusses a resurgence of interest in PHP, particularly due to the Laravel framework, which has transformed the perception of PHP among developers. The author reflects on their own journey with PHP, noting its initial appeal due to its simplicity and accessibility, but also acknowledges the negative reputation it garnered over the years due to poor design practices. The introduction of Laravel in 2011 marked a significant turning point, offering a more structured and feature-rich environment for PHP development. The author shares their experience experimenting with Laravel, highlighting its ease of use and comprehensive features, such as built-in support for various functionalities like payment processing and authentication. This newfound appreciation for PHP and Laravel suggests a shift in the developer community, where PHP is being recognized as a viable option for modern web applications. The author concludes with a sense of excitement about PHP's potential, indicating that it may once again become a popular choice for developers.

- PHP is experiencing a resurgence in popularity, largely due to the Laravel framework.

- Laravel offers a structured environment with extensive built-in features, improving the development experience.

- The author reflects on their past experiences with PHP and acknowledges its previous shortcomings.

- The article suggests a shift in the developer community's perception of PHP as a viable option for modern applications.

- The author expresses newfound enthusiasm for PHP and its capabilities through Laravel.

Link Icon 30 comments
By @dubcanada - 8 months
I find it funny the author choose Symfony as a framework to "shudder" about. Considering the base of Laravel is Symfony.

The rest of the article seems to be more about AI code editing and MUX video players then PHP.

So I am not really sure what I am supposed to take from this post.

By @jf - 8 months
Why choose between PHP and JavaScript when you can write code in CASSIS, a language that runs in the syntactical intersection of both languages?

For example:

  if (js()) {
   /* javascript */
  }
  else {
   /* PHP */
  }
https://github.com/tantek/cassis
By @ljm - 8 months
I don't understand this post; the author is just shilling Laravel; the entire post is an advert for Laravel with a clickbait title.

The content of the article is describing the concept of a full stack framework, as if Laravel is the novel solution to it.

How in god's name is this tripe upvoted on HN?

By @mintone - 8 months
The comments on this thread are interesting. I use Laravel extensively. For big applications, serving lots of users. It works when the application is relatively complex, and the ecosystem is second to none. Need to just throw it up on a server? There's Forge[1]. A better CI/CD process? Envoyer[2]. Want serverless? Not for me, but Fathom[3] use it to deal with >100Ms of hits a day; there's Vapor[4]. All three of those are Laravel developed and maintained solutions.

If I'm throwing something small together then sure, I'll maybe use Flask or something lightweight[5]. But Laravel is very good for nearly every use-case where you intend to actually build something.

Then there's the bigger question: if you're building to meet a business use case, or well, to make money, then why wouldn't you use the most complete scaffold possible? I'd say Laravel is that. If it's too much of a pain to do something in PHP I can just stick in a call to a python file or really whatever language I want. But for the basics? A db? Auth? and lots of other stuff that I never want to personally build again? Yeah, give me Laravel everyday.

[1] https://forge.laravel.com/ [2] https://envoyer.io/ [3] https://usefathom.com/ [4] https://vapor.laravel.com/ [5] To prove I'm not a shill, this is from literally last night: https://github.com/simonminton/consensus-article

By @hu3 - 8 months
Related: Laravel, the PHP framework mentioned by the article, just received a $57 million investment from Accel, the same folks that invested in Sentry and Vercel.

https://laravel-news.com/laravel-raises-57-million-series-a

By @calibas - 8 months
There's been enormous improvements to PHP's performance and to the language itself over the past couple decades. It's something worthy of praise.

That being said, it's not the "new Javascript". Javascript isn't dominant because of Node.js or anything like that, but because it runs in every major web browser. Whether you like it or not, Javascript is essentially part of the web itself.

By @CuriouslyC - 8 months
PHP definitely is not the new JavaScript, but for people who want a server side solution for content delivery that's separated from the client, I'm sure it's much better than the mess it was 10+ years ago. That's still just a transition from meme level tech to valid option though.
By @vundercind - 8 months
Backwards. “Serverless” JavaScript is the new PHP. Minus the high performance.
By @conradfr - 8 months
I don't really get the hype for Laravel over Symfony, or the joy of writing prompt instead of actually coding.
By @cellardweller - 8 months
If anything, PHP is the new Java with its AbstractSingletonBullshitFactories, or some just can't resist the urge to write it that way.
By @roschdal - 8 months
Good old PHP is infinitively more easy to understand than React js soup.
By @andirk - 8 months
Laravel + Vue is a popular and straight forward framework pairing. With all the shade in these comments, there's almost no suggestion for alternatives.
By @TOGoS - 8 months
> What happened? Well. Laravel happened (and has been happening).

Funny, because Laravel was one of the things driving me away from PHP, in the same way that Rails drove me away from Ruby. PHP was becoming a salvageable language with some of the 7.0 changes, but if you don't dump 1000 pounds of gunk on top to make the easy things hard and there hard things dang near impossible, then you're not a "web artisan", I guess.

Laravel needs its own 'fractal of bad design' article. My experience was being told to use it for a work project by a koolaid-driven manager, and finding that it made our CRUD apps about 1000 times harder to write[1] and 100 times slower to execute. It seriously took Laravel 100 times longer (0.3s to 30s) just to bootstrap itself than it took our Phrebar app to handle a request including a bunch of database accesses and permission checks.

[1] Or maybe infinitely, even with code generation, because the ORM didn't support composite keys. In that way we were forced to bypass the whole thing regardless of my feelings about it.

By @pjmlp - 8 months
While I use PHP on my private site, I am in no hurry to use it beyond that.
By @tredre3 - 8 months
Bit worrying that the first code example given in the blog isn't valid PHP.

Strings are concatenated with the . operator, not +.

https://3v4l.org/v9tFN

Or in older PHP versions it would output a number (because it would cast the strings to 0).

By @pavel_lishin - 8 months
Forget the framework, forget the AI assistant. What are PHP developers like these days?

Awhile back, we wrote an MVP, a proof of concept, using Wordpress. I dug around some of the plugins and themes we used, and my god, it's still garbage. Things being shipped with huge swaths of code just commented out, spaces & tabs intermixed for indentation, TODOs littering the codebase. Things that were just flat out broken.

I used to be a PHP developer, and the habits that I learned probably stunted my professional career by a good decade. And from what I've seen - granted, in a very limited exposure - tells me that most PHP developers still write garbage code. Weirdly, I've even seen examples at work where developers write perfectly cromulent Elixir and Javascript/Typescript, but somehow revert back to the fecal firehose when it comes to writing PHP code.

I don't care how good Symfony or Laravel is. I care about what happens when my employer hires someone who can't write good code, and in my experience, the odds of that increase hugely when we talk about PHP.

By @oddevan - 8 months
To play on how every engineer is different, OP is excited about PHP because of a framework, while I'm having more fun than I've ever had explicitly _not_ using a framework!

(I am using the PSR standard interfaces[1], which means I can sub in any number of different libraries for different pieces of infrastructure. Including Laravel's. :D)

[1] https://www.php-fig.org/psr/

By @wkyleg - 8 months
What ever happened to Hack (https://hacklang.org) the language Meta built as a superset of PHP?

Why not take an approach more similar to TypeScript?

I sometimes do wonder if many of the server side rendering approaches (or alternative Node runtimes) would be better off trying to emulate some aspects of PHP

By @tengbretson - 8 months
Just use Next.js and only use server components. Bang! you're basically using PHP but with a better type system.
By @layer8 - 8 months
From the title I wasn’t sure whether it means PHP is improving or is going south.
By @durbinn - 8 months
How is this better than rails?
By @bschmidt1 - 8 months
Always thought React (specifically JSX) made JavaScript "the new PHP" in that there is markup all mixed in with syntax that is so similar to old school PHP.

"New school PHP" frameworks like Laravel are nearly exactly like Ruby-on-Rails: The same MVC style, database and ORM built-in, Laravel is so similar to Rails in many ways.

I would say:

"Laravel is the new Rails"

and

"New PHP is the old Python/Ruby"

The original dev use case for Wordpress where you can easily put up a basic CRUD app with user logins and roles/permissions was largely displaced by Django, which is just a little bit more mature of a project for such tasks than Wordpress could ever be. WP never wanted devs anyway, they wanted bloggers - so a lot of people stopped writing PHP simply because WP lost popularity as a web framework.

PHP lost a ton of up-and-coming developers to Python (esp. in academia) and JavaScript (esp. to Node), in the same way Flash/AS3 lost developers to iOS/Android. Unlike Flash, PHP never really died - just kept hanging around.

It's not a bad language, brings back fond memories at least. But there's nothing about its performance or usability that stands out, and there's no core platform need for it the way there was with Wordpress. JavaScript has the browser DOM and Node, Python has AI/ML libraries and best practices that aren't available in other languages, and in terms of another PHP use case - all the dynamic languages can quickly start an http server on localhost now. There's just no use case for PHP.

By @technojunkie - 8 months
PHP 8.x == TypeScript
By @Pesthuf - 8 months
JS has done the impossible: It made me kinda appreciate PHP. I still despise PHP for its many design (it wasn't actually designed, it just happened) failures, but I've yet to see an application running on a single server with PHP, Apache and MariaDB run slower than "modern" JS slop that needs half a cluster to run the dozens of random object DBs and caches JS devs insist on using prematurely where the application takes 20 seconds to load a simple page because the fully decoupled frontend needs to load and execute 500MB of JavaScript and that JavaScript then loads the data in 50 sequential XHRs because the API dev found a "loadAll" endpoint to be premature optimization.

...I envy TypeScript, though. I wish PHPDoc was more powerful... I just want ADTs.

By @xigoi - 8 months
Personally, I hate frameworks that generate thousands of lines of “scaffold” code with hundreds of dependencies.
By @game_the0ry - 8 months
I thought react was the new PHP.
By @VeejayRampay - 8 months
everytime I see PHP and python, it reminds that the best of the three main languages in the "slow / overly dynamic" lane (Ruby) got the short end of the stick for some reason, it's terrible
By @akagusu - 8 months
Money really changes people's perception.

For more than 1 decade Silicon Valley bros considered PHP a bad,irrelevant, legacy programming language.

Now, with a PHP framework receiving millions in funding, PHP is cool again.

By @Diti - 8 months
Wait until that person learns about FrankenPHP! https://frankenphp.dev/