WebSockets basics and PHP - php

I have been researching WebSockets for a few hours but can't seem to understand why you would need both client and server side libraries to help with WebSockets implementation?
I am using PHP so from research it seems like Ratchet is the most popular. But why would you need a server side implementation of WebSockets when server side HTML5 supports WebSockets? Can you build a chat system without the use of libraries at all? And can you build a chat system, for example, without any support on server-side, i.e. just with a jQuery library?
And how does WebSockets relate to node.js? I find it hard to get to grip with server side running JavaScript to send responses to a JavaScript front end.
Also, is this: https://code.google.com/p/phpwebsocket/ library a similar thing to Ratchet?

Related

PHP websocket documentation

I love programming using PHP. Recently I've wondered wether to spend more time learning node.js or not. Then I stumbled across PHP websocket. I saw an example making a live chat in websocket, where messages was sent in live time.
However, I can't seem to find any documentation or, better yet, explanation of what this feature actually does! Can anyone explain what PHP websocket does (technically), or send link to the correct documentation?
Wouldn't PHP websocket make it possible to push any type of content in real time to users, just like node.js can? Or have I misunderstood?
WebSockets are a bi-directional persistent connection from a web browser to a server. Read WebSocket on WikiPedia and Mozilla Web Docs
node.js and WebSocket are 2 different things. node.js is programming language built on the Google V8 JavaScript engine, whereas WebSocket is communication protocol.
Yes, WebSocket can help you push real-time updates to your client.
Here is One of the site that can help you work in WebSocket using PHP - http://socketo.me - Documentation URL : http://socketo.me/docs/

Integrating Node.js with PHP

I have an application developed in PHP. I'm completely new to node.js and would like to know how I can use node.js for status updates. I don't know node.js that well to have the whole appliction built in node.js. I would like to keep the PHP parts and just use node.js for updates and other real time features. Any tips?
The main aim of using node.js is to bypass the use of an apache server (like in the case of php) by developing your own web pages server.
You can still use node.js with your php app but this will get you into a lot of troubles.
If you want to add updates and real-time features i advice you to give it a try with websockets.
Have a look here to understand the functioning of node.js: http://www.toptal.com/nodejs/why-the-hell-would-i-use-node-js
and here for php websockets: http://socketo.me/
Good luck

Chrome web apps - server side support

Does Google Chrome web store support server sided technologies such as PHP or Python?
I am currently making a productive web application which i have already implemented in python but i wish to give it a nice little web application interface and also harness the power of PHP...
Does Chrome support Python or PHP; or does Chrome even support Server sided scripting?
I am learning how to develop chrome apps from here...
If a member is aware of any better tutorials please inform me...
Or is it that i just have to build a normal web applications and add a logo and manifest and zip it and publish it?
Thankyou...
The platform supports server-side technologies the same way a C++ or Java application would support them: through HTTP (probably RESTful) interfaces that the server side of your app (if any) exposes. For example, your app might make a request to http://example.com/api/foo/bar/baz?param1=123&param2=456, and might get back a JSON response that your app would then parse. It doesn't really matter which server-side technology you're using, because the API looks the same from the app's perspective.
If you're asking about PHP, Ruby, Python, Go, node.js, etc., running on the user's machine as a client-side app, no, that's not how Chrome packaged apps work (though in theory one could get one of those environments running as a NaCl module that then generates client-side code). Instead, you write code in a very similar way to how you'd write a pure AJAX app: in JavaScript, without navigation, with the content/data being fetched in a RESTful fashion from whatever server/service you use (or none in the case of something like a calculator or simple game that doesn't talk to the network at all). Incidentally, we're finding that very AJAXy apps are relatively simple to convert to packaged apps.
Check out all the samples at https://github.com/GoogleChrome/chrome-app-samples to get more an idea of the shape of the platform.

State of Push in web development

What is the current state of Push technology in web development? I heard solutions like Comet as described in this article are not used anymore and instead WebSocket is the future for this kind of features, but it's only supported in Chrome and Safari.
What is the best technique to use?
I'm developing a game where many players (between 2 and 4) can seamlessly interact with each others. I'm using PHP server side and Jquery in client side.
There is a solution that will work in older browsers. I don't know the finer details but I'm sure liking the blurb: (see query-graceful-websocket)
The Graceful WebSocket
So, you want to start building realtime event driven applications using the new HTML5 WebSocket API?
You want it to work in all browsers, no matter if they have WebSocket support or not
You don't want to rely on proprietary technology such as Flash to provide a fallback
And naturally, you don't want to write more than one implementation
Introducing, the gracefulWebSocket jQuery plugin:
Implements the w3c WebSocket interface
Wraps the native WebSocket if support is detected
Provides a default fallback using traditional AJAX polling over HTTP
Requires no extra code on the frontend, allows you to target the WebSocket API today and let users take advantage of it as more browsers add support.
Default fallback behavior can be overridden by plugin options
https://github.com/ffdead/jquery-graceful-websocket
I use beaconpush (Software as a Service) easy to implement, nice API, interesting functions - definitely worth a look.

Non browser based websocket clients in PHP

I was looking at Kanaka's reply to a websockets question here.
If I want to write a native app in PHP to use a websocket based webservice, where do I start? Are there any client libraries available in PHP to write native linux clients?
Basically, my server can work on a RESTful architecture for 90% of the time. However, there is one reason for the server to alert the client, so REST won't work here. So I am wondering if websockets is an answer here for me as compared to periodic polling by client.
Why not write the 90% using normal REST and do the remaining part where notifications are sent to the client using web sockets?
Here is a github project that looks like it might be what you want https://github.com/nicokaiser/php-websocket

Categories