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

Niklas Keller:
The Magic Behind Async PHP
Nov 07, 2017 @ 16:27:51

Niklas Keller has a post to his site covering the magic behind async PHP and how it can help your application gain some performance by working around the typical PHP execution flow.

Async PHP allows a massive speedup of applications by leveraging non-blocking I/O. It allows making multiple HTTP requests in parallel or any other way of I/O multiplexing. But what’s the magic behind it? How does it actually work?

He starts with a brief explanation of the difference between blocking and non-blocking I/O, pointing out that the main difference is the use of streams. He includes a bit of code to help illustrate but moves quickly on to talking about the Amp PHP package. This library allows for easier (and faster) development of non-blocking processes using an event loop. He also shares a package that was created to help make it even simpler by providing an abstraction layer on top of the Input and Output streams.

tagged: async language amp library blocking nonblocking introduction

Link: https://blog.kelunik.com/2017/11/06/magic-behind-async-php.html

Thomas Weinert:
Basics: Using Arduino From PHP
Jun 21, 2013 @ 14:33:52

In his latest post Thomas Weinert talks about using an Ardiuno board from inside of PHP (most people seem to use Python instead).

This is the version mostly described on the net. For example on Instructables. Basically you write an Arduino Scetch that listens and send plain text data on the serial port. A PHP Script triggered by a webserver request opens the port communicates with the Arduino board an outputs some HTML. The major downside of this approach is that many Arduino boards reset if the serial port is opened. So the startup and configuration has to be done any time the PHP scripts reads some data or triggers an action.

He talks about the Firmata software and an alternative to trying to call it through PHP - using one of a few non-blocking I/O libraries like React PHP. He's created his own non-blocking library that's made to work more specifically with the Firmata protocol, though. Some code samples are provided showing how to use it to make a light blink ("Hello world" for Arduino) and working with the data from a dimmer.

tagged: arduino library nonblocking caricaio firmata tutorial

Link: http://www.a-basketful-of-papayas.net/2013/06/basics-of-using-arduino-from-php.html

Brandon Savage:
Consuming RabbitMQ messages with PHP
May 31, 2013 @ 14:15:47

Brandon Savage continues his look at using RabbitMQ and PHP together to queue up requests today in this latest post. In this new part of the series, he focuses on the last piece of the puzzle - consuming the requests in the queue. (Parts one and two)

Once you’ve created a RabbitMQ producer, it’s fairly easy to create a consumer. In fact, the only difference is in exactly what commands you’re using. The connection, envelope, channel and queue declarations are the same. While in RabbitMQ you publish to the exchange, you actually do consume a specific queue. As a result, the commands for consuming are part of the AMQPQueue class.

He shows you how to set up the code to sit in the background and wait for a queue request and how to fetch them in a non-blocking way. He finishes off the post with a look at handling success and error conditions (based on the status of message consumption, not the result of the processing).

tagged: rabbitmq tutorial consume amqp library success failure nonblocking background

Link: http://www.brandonsavage.net/consuming-rabbitmq-messages-with-php

Rob Young's Blog:
Non-blocking I/O With PHP-MIO
Apr 24, 2007 @ 15:54:00

Via the Zend Developer Zone, I found out about this new article from Rob Young about using PHP-MIO to create non-blocking I/O.

A couple of weeks ago I was thinking about non-blocking I/O in PHP, specifically about how clunky PHP's select implementation is. I say clunky because it's not bad, it's just not as easy to use as it could be.

[...] I have to remember which streams I'm interested in writing to, which streams I'm interested in reading from and when I get to accepting connections, which streams are server sockets that I'm interested in accepting connections on. I'm lazy, I don't want to have to do that , I want a library to handle all that for me. At this point I decided to implement something similar to Java's non-blocking I/O in PHP5. This is now finished and up on sourceforce (under the name of phpmio). In this article I hope to give you enough information to get up and running with the package.

He explains what multiplexed I/O is (including code), what PHP-MIO is (yes, including code), and a more real life example of how to use it - a simple server that accepts connections and spits back a simple response.

tagged: phpmio nonblocking multiplexed Io tutorial phpmio nonblocking multiplexed Io tutorial

Link:

Rob Young's Blog:
Non-blocking I/O With PHP-MIO
Apr 24, 2007 @ 15:54:00

Via the Zend Developer Zone, I found out about this new article from Rob Young about using PHP-MIO to create non-blocking I/O.

A couple of weeks ago I was thinking about non-blocking I/O in PHP, specifically about how clunky PHP's select implementation is. I say clunky because it's not bad, it's just not as easy to use as it could be.

[...] I have to remember which streams I'm interested in writing to, which streams I'm interested in reading from and when I get to accepting connections, which streams are server sockets that I'm interested in accepting connections on. I'm lazy, I don't want to have to do that , I want a library to handle all that for me. At this point I decided to implement something similar to Java's non-blocking I/O in PHP5. This is now finished and up on sourceforce (under the name of phpmio). In this article I hope to give you enough information to get up and running with the package.

He explains what multiplexed I/O is (including code), what PHP-MIO is (yes, including code), and a more real life example of how to use it - a simple server that accepts connections and spits back a simple response.

tagged: phpmio nonblocking multiplexed Io tutorial phpmio nonblocking multiplexed Io tutorial

Link:


Trending Topics: