Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Gonzalo Ayuso:
Playing with Docker, Silex, Python, Node and WebSockets
Jan 03, 2017 @ 15:47:19

Gonzalo Ayuso has a new post to his site sharing some of the results of his work combining Docker, Silex, Python, Node and WebSockets, discovering how to create a complete platform with these tools.

I’m learning Docker. In this post I want to share a little experiment that I have done. I know the code looks like over-engineering but it’s just an excuse to build something with docker and containers. Let me explain it a little bit.

The idea is build a Time clock in the browser. [...] Yes I know. We can do it only with js, css and html but we want to hack a little bit more. The idea is to create: a Silex/PHP frontend, a WebSocket server with socket.io/node [and a] Python script to obtain the current time.

He then starts in on the code, first creating the WebSocket server in Node then the Python script that makes an internal request to get the time and return it. Then the Silex route is created to serve up the template for the page and the code it uses to connect back to the websocket. The post ends with the Docker configuration he used to create the Docker environment all of this lives in.

tagged: docker silex python node websockets tutorial environment

Link: https://gonzalo123.com/2017/01/02/playing-with-docker-silex-python-node-and-websockets/

SitePoint PHP Blog:
Websockets in Your Synchronous Site
Feb 26, 2016 @ 17:03:53

The SitePoint PHP blog has a new tutorial from Christopher Pitt showing you how to integrate websockets into your application for asynchronous, real-time functionality. His method makes use of a service called Socketize (with a free tier available).

Asynchronous architecture is common in other programming languages, but it’s only just finding its feet in PHP. The trouble is that this new architecture comes with a cost.

I don’t talk about that cost enough. [...] When I recommend frameworks like Icicle, ReactPHP, and AMPHP, the obvious place to start with them is to create something new. [...] It takes a lot of work to integrate new, asynchronous features into existing applications. Often there are good reasons and great benefits, but a rewrite is always a hard-sell. [...] I’m going to show you a Sockets-as-a-Service service, called Socketize.

He walks you through the setup of the code and account to create a simple CRUD (create, read, update, delete) system for a deck of cards. He starts with a simple synchronous API spitting back JSON of the card data. Then he creates the frontend client (simple Javascript) to fetch the data and append the values to the page. Next comes the asynchronous handling - he shows the creation of the Socketize account, setting up a new application (with keys) and making use of the SocketizeJavascript client to create the websocket and hook it all together.

tagged: websockets asynchronous socketize application frontend service thirdparty

Link: http://www.sitepoint.com/websockets-in-your-synchronous-site/

Gonzalo Ayuso:
POST Request logger using websockets
Nov 17, 2015 @ 16:25:32

In this post to his site Gonzalo Ayuso shows you how to create a logger for your POST requests and their information with a bit of helpful code and Websockets.

Last days I’ve been working with background geolocation with an ionic application. There’s a cool plugin to do that. [...] Basically this plugin performs a POST request to the server with the GPS data. [...] I can develop a simple Silex application with a POST route and log the request in a file or flush those request to the console. This’d have been easy but as far as I’m a big fan of WebSockets (yes I must admit that I want to use WebSockets everywhere :) I had one idea in my mind.

He shows the creation of a simple Silex-based application with just two endpoints (channel that handles both GET and POST) that uses the Guzzle HTTP library to listen on the Websockets port for incoming connections. He then shows how to add the code necessary on the frontend (using express) to send the POST data automatically to the waiting Silex application. He's provided the full working code for the example on his GitHub account as well so you can see it fully fleshed out.

tagged: websockets post log silex tutorial example gps plugin automatic debug

Link: http://gonzalo123.com/2015/11/16/post-request-logger-using-websockets/

PHPBuilder.com:
Creating Real Time Applications with PHP and WebSockets
Jul 29, 2014 @ 17:13:07

On PHPBuilder.com today there's a new tutorial introducing you to the combination of PHP and WebSockets to make real-time requests to fetch data in your application.

This article will explore the main PHP libraries used to create real time, bi-directional applications between clients and servers over WebSockets. WebSocket is full-duplex client/server communication over TCP. It is also a new feature available in browsers as a part of the HTML5 specs that allows JavaScript clients to open bi-directional socket connections to a server. [...] WebSocket connections are basically TCP socket connections that following the WebSocket rules to communicate. The WebSocket Protocol is an independent TCP-based protocol.

They introduce some of the basic concepts behind WebSockets (including an example URL) and show how to use the PHPWebSockets library to handle some sample requests. They also include some basic JavaScript to make the request to the backend PHP script and send or fetch content on the server. They also show you how to implement a simple chat server using a few other libraries like Ratchet, Elephpant.io and Socket.io.

tagged: realtime application websockets tutorial introudction

Link: http://www.phpbuilder.com/articles/application-architecture/optimization/creating-real-time-applications-with-php-and-websockets.html

Gonzalo Ayuso:
Integrating WebSockets with PHP applications. Silex and socket.io playing together.
Feb 04, 2014 @ 15:37:25

Gonzalo Ayuso has a new post today showing you how you can integrate websockets with a PHP application using a combination of Silex and socket.io, a javascript library specifically made to work with them.

WebSockets are great. We can start a persistent connection from our browser to our server and use this connection to send real time notifications to our users. Normally when we integrate WebSockets with an existing Web application, we need to face with one slight problem. Our Web application runs on a Web server (imagine, for example one Silex application). We can use a login form and ensure all requests are authorized (using a security layer). This problem is solved years ago. We can use Basic HTTP authentification, Digtest authentification, a session based athentification, token based authentificatio, OAuth, … The problem arrives when we add WebSocket server.

He mentions another solution - sharing an authentication mechanism between the frontend and backaned - but suggests something simpler using the bi-directional nature of websockets. To illustrate, he makes a simple Silex application and creates a basic template that makes the websocket request back to the localhost. He includes the simple code to make the socket.io server (node.js) and an example of using Express to handle the request and define the URL to call on the Silex application. He's also created a screencast showing the full process, start to finish.

tagged: websockets socketio silex websockets tutorial authentication security

Link: http://gonzalo123.com/2013/12/24/integrating-websockets-with-php-applications-silex-and-socket-io-playing-together

Gonzalo Ayuso:
Integrating WebSockets with PHP applications. Silex and socket.io playing together.
Feb 04, 2014 @ 15:37:25

Gonzalo Ayuso has a new post today showing you how you can integrate websockets with a PHP application using a combination of Silex and socket.io, a javascript library specifically made to work with them.

WebSockets are great. We can start a persistent connection from our browser to our server and use this connection to send real time notifications to our users. Normally when we integrate WebSockets with an existing Web application, we need to face with one slight problem. Our Web application runs on a Web server (imagine, for example one Silex application). We can use a login form and ensure all requests are authorized (using a security layer). This problem is solved years ago. We can use Basic HTTP authentification, Digtest authentification, a session based athentification, token based authentificatio, OAuth, … The problem arrives when we add WebSocket server.

He mentions another solution - sharing an authentication mechanism between the frontend and backaned - but suggests something simpler using the bi-directional nature of websockets. To illustrate, he makes a simple Silex application and creates a basic template that makes the websocket request back to the localhost. He includes the simple code to make the socket.io server (node.js) and an example of using Express to handle the request and define the URL to call on the Silex application. He's also created a screencast showing the full process, start to finish.

tagged: websockets socketio silex websockets tutorial authentication security

Link: http://gonzalo123.com/2013/12/24/integrating-websockets-with-php-applications-silex-and-socket-io-playing-together

SitePoint PHP Blog:
Building a Live-score Widget Using PHP Web Sockets
Oct 17, 2013 @ 15:11:42

On the SitePoint PHP blog there's a new post from Lukas White about using PHP and web sockets to create a "live score" widget to include in your site.

The introduction of web sockets makes it possible for web applications to handle near real-time data without resorting to "hacks" such as long-polling. One example of an application requiring up-to-the-minute data is sports scores. Even now, many websites which display this information use Flash applications, since Actionscript provides the facility to communicate over socket-based connections. However, web sockets allow us to replicate this functionality using only HTML and Javascript. That's what we're going to build in this tutorial, along with a lightweight "server" in PHP.

His example uses the Ratchet PHP library to provide the WebSockets functionality to the frontend script polling for the latest data. He helps you get the library installed and set up a simple directory structure for the example. He includes sample scripts for both the data provider (for the scores) and the WebSocket provider. He talks about maintaining the state of the data and shows how to pull out random data from a set of fixtures (pre-defined data) to send back to the frontend. The Javascript for the frontend script is also included.

tagged: tutorial websockets live score example javascript ratchet

Link: http://www.sitepoint.com/building-live-score-widget-using-php-web-sockets/

7PHP.com:
Win (TWO) Free Tickets To Hear Corey Ballou (Creating Realtime Applications w/Web Sockets)
Jul 15, 2013 @ 15:03:02

There's a new post on 7PHP.com talking about a new giveaway they're doing in collaboration with the Nomad PHP (virtual) user group and giving away two tickets for the upcoming meeting.

NomadPHP is already on their 3rd edition and I’m hence also on my 3rd Ticket(s) give-away. [...] The topic of this 3rd talk will be centered around PHP and Websockets and will be presented by speaker Corey Ballou.

There's two ways to enter into the contest - either subscribe to their mailing list or Tweet about it (with the given tweet). The contest ends July 21st, so hurry and enter if you're interested. The Nomad PHP user group is "a (virtual) place to call home" if you don't have a user group in your area. It meets online once a month.

tagged: contest tickets coreyballou realitme websockets nomadphp

Link: http://7php.com/nomadphp-july-2013-free-tickets

Nomad PHP July 2013:
Corey Ballou - Creating Realtime Applications with PHP and Websockets
Jul 04, 2013 @ 18:19:26

The Nomad PHP virtual user group has announce the latest meeting - this time it's Corey Ballou presenting about realtime applications and WebSockets in July.

We’ll start out with a brief introduction to WebSockets to get everyone up to speed before jumping in to high level scaffolding code of the frontend and backend implemetations (the spec). Once the groundwork has been laid, I’ll introduce you to a both client and server side tools for implementing WebSockets directly in your PHP code. From here, we’ll jump into multiple interactive demos of increasing complexity utilizing the open source Ratchet library. I’ll walk through the source code of the first two intro demos to give you a better sense of how to structure your own WebSockets applications

If time allows, I’ll run through a complex demo where I introduced WebSockets to an existing CRUD todo application. The last demo is not for the faint of heart. By the end of the presentation, you’ll walk away with access to a github repository containing all of the presentation slides and demos ready to run yourself!

You can pick up your tickets for this meeting (happening July 25th) directly from the Nomad PHP site.

tagged: nomadphp coreyballlou realtime applications websockets virtual usergroup

Link: http://nomadphp.com/2013/06/06/july-2013/

PHP Town Hall Podcast:
Episode #7 - Web Sockets Are Fast
May 20, 2013 @ 16:41:55

The PHP Town Hall podcast has posted a new episode - Episode #7: "Web Sockets Are Fast".

Chris Boden joins us to talk about a Ratchet and React. The conversation is basically Ben and Phil asking a bunch of questions about how Ratchet works, pretending we know what is going on while Chris uses lots of words like “concurrency” and “non-blocking”. We decide that PHP is web-scale, event-driven programming is not just for NodeJS hipsters, we all take the “Are You a Brogrammer” test and Michael Wales crashes the show half way through like a ninja.

You can listen to this latest episode either through the in-page player or by downloading the episode directly. You can also subscribe to their feed if you'd like the latest shows as they're released.

tagged: podcast phptownhall websockets philsturgeon benedmunds

Link: http://phptownhall.com//blog/2013/06/18/episode-7-web-sockets-are-fast


Trending Topics: