2015年5月11日星期一

Gonzalo Ayuso: PHP Dumper using Websockets


Gonzalo Ayuso has a quick post to his site showing you how to make a "PHP dumper" for websocket connections based on a simple Silex application.



Another crazy idea. I want to dump my backend output in the browser's console. There're several PHP dumpers. For example Raul Fraile's LadyBug. There're also libraries to do exactly what I want to do, such as Chrome Logger. But I wanted to use Websockets and dump values in real time, without waiting to the end of backend script. Why? The answer is simple: Because I wanted to it.


He shows how to create a simple socket server (with Express in Javascript) and the basic Silex application with a "DumperServiceProvider" added in that will handle returning the debugging data back to the waiting client. He connects the Silex application with the websocket and shows the code to listen for new messages on the socket and display them back out to the browser. You can see an example of the end result in this video on YouTube.


Link: http://gonzalo123.com/2015/05/11/php-dumper-using-websockets/

没有评论:

发表评论