Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I want to make an IM so that user's can send instant messages to each others on the same page like a chat. Users can choose that who can see their messages. Its for task management . What is the best method that I should use for. I'm using php. Is php sockets usefull for this? or Polling, Comet, php output buffer or javascript timer(timer is easy but not fast).
The most frequently used method is called COMET.
Here is a PHP implementation: How to implement COMET with PHP
In the HTML5 specification there are something called websockets that many browsers already have implemented. Here is a PHP project supporting websockets: phpwebsocket. There are some javascript libraries which can use a flash component if the browser do not support websockets (and therefore be backwards compatible)
imho webSockets is the way to go, although PHP might not be the most suitable backend to handle them.
If you know how to use Sockets then use them; otherwise using AJAX in a timer should suffice so long as it doesn't need to be real-time (5-10 second delays between fetching messages should be OK).
I'd suggest using Socket.IO for this.
You have a few options from PHP:
As pointed out by #jgauffin you could look doing this on your existing PHP server using a Comet using the Comet and PHP option or WebSocket Solution using something like phpwebsocket.
You could create another component dedicated to handling your real-time messaging such as a dedicated Comet or WebSockets process running on you existing hosting or a wholly dedicated server. If you take this approach you could look at using something like socket.io running in node.js or a full third party Comet or WebSockets server.
Finally, you could have a look at a hosted service which would allow you to keep your existing development and production environment and you could then layer on the real-time chat. One such service called Pusher (which I work on) handles all the real-time messaging infrastructure in addition to providing added functionality specifically developed for making chat applications easy to build. It also means that you don't need to upgrade your hosting if you are using something like shared hosting where things are tightly locked down and you can't easily install your own components.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want to implement real time notifications like in Facebook. There might be a huge number of notifications to be sent for different users, depending on server load time and efficiency of coding. Which is the best approach?
1. using normal AJAX?
2. with node.js and socket programming?
3. something else?
Thanks in advance.
The choice of the proper platform greatly depends on your current architecture, knowledge, and budget.
Your question suggests that it is web based, for which there are only two basic options:
WebSocket: There exists many WebSocket server solutions including compiled executables, PHP based, and Node.js. This approach is greatly gaining in popularity but isn't necessarily accessible to every budget since it usually requires a complete server to run. VPS limitations are usually too important for systems that require so many simultaneous connections.
AJAX: The use of AJAX and its variants is still a very popular solution and, when well implemented, can be almost as efficient as WebSocket without the need to sustain the connections constantly. It doesn't often matter if there is a one second delay, and Facebook chat is usually much slower than that.
For non web-based solution, anything is possible. If you develop a client-server application, you can have real time connections similar to WebSocket which can be even easier to maintain.
Ajax request not real time but you can set timeout and in this case work.
but the ajax request busy your server and try to many connections. this is simple !
If you use socket it's better but you need more time to develop this.
Read the following link can help you :
Ajax vs Socket.io
Nowadays we have two possible solutions. WebSockets and Comet. WebSockets are probably the best solution but they’ve got two mayor problems:
Not all browsers support them.
Not all proxy servers allows the communications with websokets.
Because of that I prefer to use comet (at least now). It’s not as good as websockets but pretty straightforward ant it works (even on IE).
realtimenotifications more details To know more about refer above link.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I am currently working on a project where I need a backend for a mobile (iOS) and web application. For another project that I worked on a while ago, I used Parse.com as the backend since I did not have to deploy the application to the general public.
Since the application I want to launch may have a sudden burst of requests I wanted to use another service. Therefore, I am currently working on a PHP/MySQL backend that receives http requests and returns JSON encoded data.
Would this be an ideal setup for a scalable backend or is there any other service such as www.backendless.com that would enable me to have the same functionality without having to code everything myself?
I'm not an experienced backend developer and I am currently using most of my time on the backend and not working on the front-end.
Thanks.
PHP is a good language to start with and it's good enough (though not the best), first you need to choose a framework to help you getting what you want faster & more optimized and I suggest the Phalcon PHP framework, this one use some components from the C language which makes it faster than the others
After getting good in PHP please read more about the Restful APIs, because that's how you will handle the data for a mobile application.
And if you want a service for the backend like Parse I suggest Firebase for you, hope my answer helped. Good luck with your app.
Everyone knows Parse is going to be unavailable so next ready option for BaaS is Firebase but keep in mind there are many things that are not Supported by Firebase unlike Parse, for example image storing, push notifications ...
Another option is AWS Mobile Hub
I have been using Cakephp for my last 5 projects, creating backends to use as cms and as rest API (in my case I used JSON as response, but there are other formats). [http://book.cakephp.org/2.0/en/development/rest.html]
It is very easy to create your models, controllers and get started with your API. It also provides a lot of authentication methods, etc.
Parse is shutting down so it is not an option.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to make an application where users use their own computer together with a host, the host click ”Start” and then there shall automatically show a button on all users computers at the same time. Then the first person who click the button will win. I want this to happen in the browser, but I dont know wich technology to use. I already know PHP and mysql, but I dont know anyway to update users computers in realtime. Wich technology would be the best choice to make this happen?
The solution here is basically web sockets, likely with a pub/sub layer on top. It can be done relatively simply with a decent Javascript and server-side library. PHP isn't the ideal language for this, but it works just fine with the right tools. Ratchet is a decent PHP web socket server implementation, and Autobahn|JS a decent client-side library (note: at the time of writing the latest Autobahn|JS WAMP implementation is incompatible with the older WAMP implementation of Ratchet, use Autobahn|JS WAMP v1). Follow the Ratchet tutorial, then expand into setting up a pub/sub server as described here (you don't need the ZeroMQ components, you'll be triggering events by a publish action instead of an external ZeroMQ event).
That's a 30,000 foot overview, go forth and try it.
Pusher.com has the ideal solution for this. You can send events, listen to these events and then respond accordingly. They have a free plan which I think is way more than you will probably need. Pusher works with JavaScript and it's extremely simple to get started
I suggest reading up on the documentation at pusher.com/docs
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have a client that wishes to have a website written that involves a fairly simple cms driven website that sorts and displays daily reports. The website will require subscriptions and include membership, free trials, etc...
Originally I was going to write the site in PHP, as none of the requirements are too heavy and I am very experienced in it. However, after speaking with the client, he has worked closely with someone who has a C++ product that offers a workflow that includes the entire process of handling subscriptions, logins, and trials and (apparently) can be used on a web platform.
This throws a wrench into my original plan, because even though I know C++ I have never had to deploy it on a webserver or have it communicate with PHP. I've already written a good deal of the site in PHP, so would prefer not having to re-write.
Can I have the two communicate on the same server? What would be required to do so? Would it be worth my time or should I just decide to scrap PHP and use C++? Or should I tell my client he's nuts?
That's about all the info I have about the project right now. Not sure if I can provide much more info, but will try if it's needed.
Thanks for all answers.
Tel him he is nuts.
The reason is that none of those tasks requires the benefits C++ can offer over PHP. It is heavy maintenance pain. And in the big picture putting those two together is more work (in hours) than writing those things in php.
The only thing that would justify C++ is if there is some heavy math business logic involved in there. And i mean heavy.
For problems. Just think about debugging.
In addition to what Thomas says (which is all true), your hosting company will most likely prohibit running custom binaries. Hosting packages short of virtual private server normally don't allow user-written compiled code on the Web server, only scripts.
VPS hosting is, on average, 5 times as expensive.
You can re-write the C++ code in PHP. You can also convert C++ to Java using a converter and then use the Java virtual machine if your host allows that. You can use the C++ code if your host allows that. You can host the C++ code from a local machine if that is a good idea in your case.
I would tell the client that in case there is no explicit need for the C++ language I would go with implementing PHP. You know, the communication between C++ and PHP adds to server load even if the host allows you to use the C++ module. And in the future you will have a lot of pain maintain
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have a GoDaddy Linux hosting , any idea how do I run a websocket server for my HTML5 web app ? Any other recommendation ?
I know VPS can do it, but it is costly , any PaaS solution ?
If you have a shared hosting plan, you will very likely not be able to access sockets, thus making it impossible to use the WebSocket API.
You're going to need a virtual private server for this one.
If you got that set up you can take a look at socket.io and node.js which does exactly what you're looking for. There are a couple of examples of how to set it up on their websites plus you can take a look at this blog post which has some examples on how to set up node.js and socket.io with html5's canvas and websockets to have some realtime drawing going on.
Edit: Theres a second option of running a php based socket server, although not as good as the option above, but it can probably(?) be done without vps.
PHP has seme basic functions to create a socket server that are listed here. There are a couple of examples of how to set it up such this. And theres also this stackoverflow answer here that lists a couple of google code projects that does exactly what you need such as this.
The best PHP WebSocket self-hosted/install solution right now is Ratchet.
However, as stated by #HartleySan, you're unlikely to be allowed to use a WebSocket solution on a shared plan due to the requirement for persistent connections. This is especially the case with general PHP solutions that allocate a large amount of resource to each request. Ratchet may have worked around this, I don't know.
IMHO the best solution for PHP is to use a hosted service such as Pusher, who I work for. There are other realtime web hosted solutions available too. This means you offload the persistent connections to the hosted service and can use your PHP stack in the normal way.
Also related: OpenShift, a PaaS, have written an article which covers the challenges of WebSockets. This helps explain the problems that other hosting providers are having when supporting WebSockets.
OpenShift do have WebSocket support in preview so you could try them out. But that is obviously a problem if you've already paid for your shared hosting. As above, I'd recommend a hosted service as the best solution.