Nishchit
Nishchit

Reputation: 19084

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

Upvotes: 4

Views: 7639

Answers (2)

Norbert Pisz
Norbert Pisz

Reputation: 3440

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.

Upvotes: 9

ksimons
ksimons

Reputation: 3826

You don't need node.js if you don't want it. I wouldn't try mixing node and php.

If you want to use socket.io with php, take a look at elephant.io: http://elephant.io/#usage. I think it'll suit your needs.

Upvotes: 2

Related Questions