Combining ReactPHP and ReactJS — Part I

Lochemem Bruno Michael
4 min readMar 6, 2021

This text is the first in a series of articles whose purpose is to demonstrate how to build apps that combine the multiple potencies of ReactPHP and ReactJS.


There exists a plethora of stacks — combinations of technologies (languages and-or frameworks) typically canonized as fancy abbreviations reflective of individual amalgam components (LAMP, MERN, MEAN, and the like) — for the development of web-based apps. ReactPHP and ReactJS, near-complete homophones (perfect if you remove the language-specific suffixes) though potent on their own, are immensely robust when used in tandem. The former is a powerful suite of event-driven PHP technologies, and the latter is a popular library whose primary purpose is enabling the creation of user-interfaces. A general scarcity of elaborate textual descriptions of tandem-use of ReactPHP and ReactJS is the impetus for this text — and series, whose viability is pushing the said ideas into technical orthodoxy.

ReactJS — The “Fake” React?

Created circa 2013 by Facebook, ReactJS has, since its inception, become a staple of modern application development. ReactJS powers a bevy of open-source and proprietary bespoke projects — and continues to be blogged about, seemingly ad-infinitum. It has, through multiple versions, served its purpose as a tool for the creation of robust User Interfaces for the web — and has even spun off into the mobile development scene (with significant nuance). Assuming that you, the reader, have some proficiency with React’s idiosyncrasies (localized component state, JSX, and lifecycles), integrating React into a dual React-powered application should be a somewhat easy proposition. For those unfamiliar with ReactJS, the following snippet should suffice as a showcase of the aforestated ideas.

ReactPHP — The “Real” React?

Often derided for many reasons — a lack of support for asynchrony being one of them — PHP remains a leviathan in the vast seas of web development. ReactPHP, first released to the public sometime in 2012, is a viable ameliorator of all such derision. Packaged as a set of asynchronous utilities — an event loop, promises, HTTP client and server components, as well as filesystem and child process interaction tools — ReactPHP is a nice infusion of non-blocking I/O in an overwhelmingly synchronous PHP ecosystem. Think of it as Node.JS for PHP — that can run sans-C/C++ extensions — atop idiomatic PHP — and is supercharged by them (libuv + ReactPHP = Rinnegan type chakra).

The real React — often referred to as such in some small circles of the web — is, by virtue of being a non-blocking I/O solution, a means of increasing PHP’s capacity for processing application throughput. It leverages the power of an event-loop and processes, in interleaved sequences, arduous I/O operations. One of the many tractable benefits is the easy creation of long-running processes — HTTP servers, daemons, and the like: applications infrequently mentioned in relation to the PHP language. A simple HTTP server, like the one shown below, is a neat application of the ReactPHP suite — and is a strong basis for the entries to follow.


Combining ReactPHP and ReactJS entails defining server-side operations with the former and creating an apt interface with the latter. The technical overlaps between Node.JS — frequently used in conjunction with the other React — and ReactPHP might bode well for those looking to mimic the event-driven Node.JS model and provide a different perspective to PHP users largely unfamiliar with production-affable asynchronous PHP. Generally, combining both React libraries means melding event-driven PHP with brilliantly quirky but — nevertheless — reliable JavaScript.

From a strategy-perspective, the approach to conjunctive ReactPHP-ReactJS use proffered in this series is defining a consumable RESTful API in ReactPHP and a poignant interface with a multitude of ReactJS artifacts and ideas.

To be explored further, in the next piece, are foundation ReactPHP and ReactJS principles concerning a simple phonebook application.