DEV Community

mirnatul
mirnatul

Posted on

The PHP Project That Inspired React

 📃The PHP Project That Inspired React

Before React, there was XHP 🧩
XHP (eXtensible Hypertext Preprocessor) was Facebook’s PHP extension that let developers write HTML directly inside PHP—safely and without messy string concatenation.

Instead of:
echo "<div class='user'>" . $userName . "</div>";

You could write:
<div class="user">{$userName}</div>

💡 Fun fact: React’s JSX was inspired by XHP!
The same ideas—structure, safety, and reusable UI components—eventually evolved into React’s component-driven model.
💻 ➡️ ⚛️ Next time you write JSX, remember where it all began!

Top comments (2)

Collapse
 
xwero profile image
david duymelinck

Not 100% correct, it is a Hack library.
If you would have looked at the repository you should have seen that.

I don't think the library inspired JSX. I think the idea to use HTML-like code instead of strings was language agnostic.

The first release of the library was in 2010 and the first React release was in 2013. So the library was developed sooner, but it is faster to develop a single purpose library than a view library.

Collapse
 
mirnatul profile image
mirnatul

Thanks for the clarification! 🙌
You’re absolutely right — XHP was a Hack library, and JSX wasn’t directly inspired by it. They both came from the same philosophy of writing cleaner, safer, and more structured UI code, rather than mixing messy strings with logic.