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
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
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.
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 have alredy PHP. You can use 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 sockets calls and PHP server for API calls.