So... Is this PHP's Redemption? 😳
Tags: php, webdev, programming, discuss
Published: 2023-05-13 13:27:33

## Is PHP rising from the dead?
Unbelievable yet true... PHP is trending on social media.

{% twitter 1656321343804289032 %} 

## Why is this unexpected?
Well... If you're a developer and you've been on the internet the last couple of years, you must have stumbled across at least one meme/article announcing PHP dead for good.

But why is that?

## The rise and fall of PHP

### The rise of PHP
It's the year 1994. A developer called [Rasmus Lerdorf](https://de.wikipedia.org/wiki/Rasmus_Lerdorf)
creates a set of Common Gateway Interface (CGI) scripts, which he uses to maintain his (**P**)ersonal (**H**)ome(**P**)age.
PHP's name later evolved to something more fancy, of course 😅 - "PHP: Hypertext Preprocessor".

It quickly evolved into a full-fledged programming language and became one of the most popular languages for building web applications. 📈📈📈

PHP's early popularity was driven by its simplicity and ease of use, making it accessible to developers of all skill levels.

### PHP's architecture

PHP's paradigm is unbelievably simple:

**File based routing (in most cases)**
The URL/path of a page is made up of the folders and `.php` files contained in them.
 
**Server-Side-Rendering**
The user makes a request to the server and the server generates the HTML for the page dynamically (with the ability of fetching data from a database, for instance, and rendering HTML for that data before sending the HTML back to the user).

### PHP's arch-nemesis
However, **PHP's dominance began to wane** as new languages and frameworks emerged that were better suited for building modern and interactive web applications. ☹️

Front end frameworks such as **React, Angular, and Vue.js** provided developers with more powerful tools for building complex, interactive user interfaces. 📈📈

A lot of websites began adopting the **Single Page Application** approach of these frameworks where you don't have to reload the entire page all the time and instead only fetch data from the server and let your front end framework render the HTML for the page on the client side.

### "PHP is dying"

As we can see on [Google Trends](https://trends.google.de/trends/explore?date=all&geo=DE&q=PHP&hl=de), PHP's relevance is on the decline:

![Google Trends Chart for PHP](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mk18p11ecd5kme1vlvoh.jpg)



However, according to W3Techs:
> PHP is used by 77.5% of all the websites whose server-side programming language we know.


This means PHP still holds a market share like no one else.

**So is PHP dying? No.** PHP is here to stay for years if not decades to come.

However, its relevance has undeniably been on the decline for quite some time now.

## So- Why is PHP trending then?
### 1. JavaScript frameworks
Even though JavaScript frameworks are probably the biggest reason for PHP's decline in terms of relevance, they are also the biggest reason everyone seems to be talking about PHP again right now.

**JavaScript frameworks like React and Vue.js are awesome! But their client-side rendering approach has some drawbacks.**

One of the biggest being that the entire page is rendered at runtime in the client's browser.

Not only does it result in more network requests and a longer time until the user can interact with the page (after it loaded up), it also hurts **SEO (Search Engine Optimization)**.

That is because nobody knows how well search engines can run the client-side rendering logic and the initial HTML sent to the client (or web crawler) is just an empty HTML skeleton. 😕

**This is why we see JavaScript frameworks like [Next.js](https://nextjs.org/) or [Nuxt](https://nuxtjs.org/) adopting the concept of Server-Side-Rendering** and generally code executed on the server to hydrate pages.

Next.js even adopted a file-based routing system... _Does all that sound familiar to you?_ 🤯

Next.js is also adopting [React Server Components](https://nextjs.org/docs/getting-started/react-essentials#server-components) - Components entirely rendered on the server, even when updated.

And Next.js recently introduced the concept of ["Server Actions"](https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions) - Functions of code executed on the server and used, for instance, to query data from a database:

```javascript
import { sql } from '@vercel/postgres';
import { redirect } from 'next/navigation';

async function create(formData: FormData) {
  'use server';
  const { rows } = await sql`
    INSERT INTO products (name)
    VALUES (${formData.get('name')})
  `;
  redirect(`/product/${rows[0].slug}`);
}


export default function Page() {
  return (
    <form action={create}>
      <input type="text" name="name" />
      <button type="submit">Submit</button>
    </form>
  );
}
```
Source: https://vercel.com/changelog/vercel-postgres

This reminds people a lot of PHP and has caused a flood of memes and comparisons, making people talk about PHP again.


### 2. PHP 8
**PHP, to many developers, is nothing more than a memory.** In fact, what many developers remember when they think about PHP is **PHP 5, released in 2004**.

PHP 5 is ancient and had a lot of issues. However, because it is unfortunately still in use on a lot of websites, a lot of PHP's bad reputation goes back to these older versions of PHP.

**However, PHP has had an unbelievable development throughout the recent versions (especially 7 and 8).** 🚀

A lot of the bad design choices and security vulnerabilities of the past versions, which unfortunately hurt PHP's reputation a lot, are now gone 💨 And the developer experience is much better which makes PHP a great choice even for modern projects.

## Conclusion... Will PHP take over again? 🔮
Good question... I don't know.

But the real question is: Does it matter?

Because in my opinion, what really matters is the developer behind an application and their skills and ideas 👩‍💻🧠

There are developers who build incredible web apps and websites with **Laravel** or **WordPress** and then there are developers who build incredible apps with **React**.

Both worlds are great and every programming language/framework has something unique to offer. I doubt anyone would regret choosing either of them at any point as long as they know how to make the best of it. 🤷‍♀️

**But what do you think?** Feel free to join the discussion in the comments. I'd love to hear your opinion!

Cheers.