PHP + Node.JS

Why Node.JS?

Prerequisites

  1. A computer running both PHP and Node.JS
  2. Way to make local HTTP Requests (cURL or anything)

Let’s make PHP and Node.JS Friends

  • When a user sends a message, you send an AJAX request to a PHP script (message.php) and updates the database adding the new message into it.
  • Now the problem occurs. We need to notify the user in the other end about this message, right?

Setting up Node.JS server

  1. Clients connect to the server via WebSockets.
  2. PHP scripts connect to the server via password protected HTTP Requests.

Let’s Continue

Connecting client-side to Node.JS

Conclusion

--

--

--

Founder of Hyvor

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Supun Kavinda

Supun Kavinda

Founder of Hyvor

More from Medium

PHP and NODE.JS

Clear old elements on Redis Cache with Laravel

Laravel 9: Enums!

laravel 9

Inertia.js — Build a Single Page Application without API