Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular with socket.io & backend php

I am working on realtime app (chat) & using angular and my backend is php(codeigniter restapi) for database in mongodb I hear somewhere that socket.io is best library for socket (use for real time) , and i see socket.io is mostly use with node.js , so may i need basic knowledge of node or any other feasible way to work with socket.io , angular and php

like image 217
Nishchit Avatar asked Dec 19 '22 23:12

Nishchit


1 Answers

You have 3 ways:

Use node.js server

It depends how large is your API. But in my opinion for MongoDb and sockets node.js will be better than PHP.Why? MongoDB using JSON format and NodeJS is javascript server so it is better to handle JSON. Also NodeJS have non-blocking IO so it will be faster for socket than PHP. You can read more Here. NodeJS is very simple to learn.

Use PHP with sockets

You don't need to start new node.js server if you already have PHP. You can use a library similar to socket.io. Lets check: Elephant IO

Use PHP for API and Node for socket only

I think you don't need to use all data from API for socket. So you can create node server only for socket calls and PHP server for API calls.

like image 104
Norbert Pisz Avatar answered Dec 31 '22 04:12

Norbert Pisz