<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Sun, 19 May 2013 20:13:32 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Segment.io: How to Make Async Requests in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/19142</guid>
      <link>http://www.phpdeveloper.org/news/19142</link>
      <description><![CDATA[<p>
On the Segment.io blog there's a new post by <i>Calvin</i> talking about <a href="https://segment.io/blog/how-to-make-async-requests-in-php/">making asyncronous requests in PHP</a> and three different approaches you could use, depending on your situation.
</p>
<blockquote>
When designing client libraries to send data to our API, one of our top priorities is to make sure that none of our code affects the performance of your core application. That is tricky when you have a single-threaded, "shared-nothing" language like PHP. [...] Ideally, we like to keep the setup process minimal and address a wide variety of use cases. As long as it runs with PHP (and possibly a common script or two), you should be ready to dive right in. We ended up experimenting with three main approaches to make requests in PHP. Here's what we learned.
</blockquote>
<p>
Their three suggestions don't involve external dependencies (like a queue server) and can operate pretty quickly:
</p>
<ul>
<li>Opening a socket and closing it before waiting for a response
<li>Write to a log file (a pseudo-queue)
<li>Fork a curl process (through something like <a href="http://php.net/exec">exec</a>)
</ul>
<p>
They each have small code examples included with them and explanations as to their plusses and minuses. For their needs, the "forked curl" solution worked out the best, but check out the other options too - you might have different needs.
</p>]]></description>
      <pubDate>Wed, 06 Feb 2013 09:52:49 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Francois Zaninotto's Blog: Node.js for PHP Programmers #1: Event-Driven Programming... and Pasta]]></title>
      <guid>http://www.phpdeveloper.org/news/17450</guid>
      <link>http://www.phpdeveloper.org/news/17450</link>
      <description><![CDATA[<p>
On his blog today <i>Francois Zaninotto</i> has a post that aims to <a href="http://dotheweb.posterous.com/nodejs-for-php-programmers-1-event-driven-pro">introduce those with a PHP background to how Node.js</a> works. In this first part of his series, he tries to explain the idea of event-driven programming - parallel processing of different parts of an application based on some action taken in the code.
</p>
<blockquote>
For a PHP developer, asynchronicity is the most puzzling aspect of the Node.js runtime. It's simply a new way to write programs. And once you pass the first learning steps, event-driven programming opens a world of possibilities PHP programmers would never dream of. I'll try to explain you how it works, but first, let's talk about pasta.
</blockquote>
<p>
In his "pasta" example, he shows how a typical PHP application would make a "Pan" object, call a "warm" action, "add olive oil", etc. All of this happens in sequence, though and takes 29 "minutes" to complete. To help things along, he implements an "EventLoop" class that handles tracking the timing and includes two methods to execute callbacks and delayed methods. He expands on this example with asynchronous objects and method calls to handle multiple things at once. He relates this to what Node.js offers - a built in event handling system, an included EventLoop object and native blocking I/O operations. 
</p>]]></description>
      <pubDate>Thu, 26 Jan 2012 08:35:41 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Gonzalo Ayuso's Blog: Speed up PHP scripts with asynchronous database queries]]></title>
      <guid>http://www.phpdeveloper.org/news/15260</guid>
      <link>http://www.phpdeveloper.org/news/15260</link>
      <description><![CDATA[<p>
In a new post to his blog <i>Gonzalo Ayuso</i> has <a href="http://gonzalo123.wordpress.com/2010/10/11/speed-up-php-scripts-with-asynchronous-database-queries/">a suggestion for speeding up your scripts</a> that use multiple database connections, possibly ones with larger queries that could take a while to run - asynchronous query handling.
</p>
<blockquote>
That's the situation. A web application with 4 heavy queries. Yes I know you can use a cache or things like that but imagine you must perform the four queries yes or yes. As I say before the four database queries are heavy ones. 2 seconds per one. Do it sequentially, that's means our script will use at least 8 seconds (without adding the extra PHP time). Eight seconds are a huge time in a page load. So here I will show up a technique to speed up our website using asynchronous calls.
</blockquote>
<p>
Since PHP doesn't really support threading, he works around it by creating a separate script for each of the queries (obviously only practical for special cases) as a self-contained unit. Then the "master" script that needs the results of the queries calls each of them via asynchronous <a href="http://php.net/curl">curl</a> class (simply named "Fork") that sends off the requests and waits for each result to come back as a json result set.
</p>]]></description>
      <pubDate>Mon, 11 Oct 2010 11:49:53 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Kevin Schroeder's Blog: Could your PHP application benefit from asynchronous computing?]]></title>
      <guid>http://www.phpdeveloper.org/news/15228</guid>
      <link>http://www.phpdeveloper.org/news/15228</link>
      <description><![CDATA[<p>
<i>Kevin Schroeder</i> has been conducting an informal poll about asynchronous computing in PHP applications and has <a href="http://www.eschrade.com/page/could-your-application-benefit-from-asynchronous-computing-4ca9de5a">posted some of the results</a> (as well as the poll for those that didn't get their votes in) to his blog today.
</p>
<blockquote>
Tis the season for Zendcon.  I am going to be giving a talk at Zendcon called "Do You Queue".  It will be about doing asynchronous computing in PHP.  In order for me to gather some data I posted a twitpoll poll.  The response has been pretty good.  However, there have also been several misunderstandings as well. 
</blockquote>
<p>
He points out a few comments on the poll that talk about asynchronous processing being included in the language and dismiss it as something that other technology already does. He agrees that threads shouldn't be in PHP because it would break on of PHP's strongest features - the Shared Nothing architecture. Want to share your opinion? <a href="http://www.eschrade.com/page/could-your-application-benefit-from-asynchronous-computing-4ca9de5a">Vote on the poll</a> and be heard!
</p>]]></description>
      <pubDate>Tue, 05 Oct 2010 08:42:16 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Kevin Schroeder's Blog: You want to do WHAT with PHP? Chapter 6 & 7]]></title>
      <guid>http://www.phpdeveloper.org/news/15130</guid>
      <link>http://www.phpdeveloper.org/news/15130</link>
      <description><![CDATA[<p>
<i>Kevin Schroeder</i> has posted excerpts from the <a href="http://www.eschrade.com/page/want-what-with-chapter-4c8a4c56">sixth</a> and <a href="http://www.eschrade.com/page/want-what-with-chapter-4c8f71e1">seventh</a> chapters from his "You Want To Do WHAT With PHP?" book.
</p>
<p>
<a href="http://www.eschrade.com/page/want-what-with-chapter-4c8a4c56">Chapter 6</a> focuses on asynchronous processing and the excerpt talks about doing it with a little big of encryption on the side.
</p>
<p>
In the excerpt from <a href="http://www.eschrade.com/page/want-what-with-chapter-4c8f71e1">Chapter 7</a> he looks at a more structured way to access files rather than just the random <a href="http://php.net/fopen">fopen</a> or <a href="http://php.net/file_get_contents">file_get_contents</a>. There's a code example in this one showing how to get the header information off of a file for things like file type, last modified time, a header checksum and the file's permissions.
</p>]]></description>
      <pubDate>Wed, 15 Sep 2010 08:16:53 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Daniel Jensen's Blog: Database gearman worker in PHP example]]></title>
      <guid>http://www.phpdeveloper.org/news/14967</guid>
      <link>http://www.phpdeveloper.org/news/14967</link>
      <description><![CDATA[<p>
<i>Daniel Jensen</i> has <a href="http://www.echodevil.com/blog/1043/Database+gearman+worker+in+PHP+example.html">a new post</a> about using <a href="http://gearman.org">Gearman</a> to do some simple database inserts asynchronously.
</p>
<blockquote>
If you need to do a lot of inserts in your DB with a certain line of order they should be carried out in or with a clean-up script following after the inserts and you don't have to wait for a reply from MySQL, the answer to that problem might be this worker written in PHP for Gearman as an interface for your DB. A MySQL crash or a worker crash will have no impact on your inserts because they will just stay in the Gearman queue until the system is running again.
</blockquote>
<p>
He includes a code snippet showing a sample database Gearman worker written in PHP to run simple database queries. His example uses a simple database connection (a basic wrapper around a <a href="http://php.net/mysql_query">mysql_query</a>) and the line of code to run the worker. 
</p>]]></description>
      <pubDate>Mon, 16 Aug 2010 14:51:25 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Sameer Borate's Blog: Parallel cURL execution in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/14907</guid>
      <link>http://www.phpdeveloper.org/news/14907</link>
      <description><![CDATA[<p>
New on his blog today <i>Sameer Borate</i> has a post looking at his method for making <a href="http://www.codediesel.com/php/parallel-curl-execution/">parallel connections with curl</a> based on <a href="http://github.com/petewarden/ParallelCurl">this library</a> from <i>Pete Wardens</i>.
</p>
<blockquote>
Most people use the 'easy' mode - in this mode when we issue multiple requests, the second request will not start until the first one is complete. This is known as synchronous execution, and this is the one we normally use. [...] In [multi] mode all requests can be handled in parallel or asynchronously. And it can be quite handy and time saving on many occasions. 
</blockquote>
<p>
He gives some code examples of how to use <a href="http://github.com/petewarden/ParallelCurl">the library</a> to simplify the curl connections and requests and pass the result off to a callback when it's done. His more practical example shows how to search for a set of terms on Google and return the results for output.
</p>]]></description>
      <pubDate>Thu, 05 Aug 2010 09:56:05 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Ibuildings techPortal: State & Ajax - How to Maintain Browser and Application State in an Asynchrono]]></title>
      <guid>http://www.phpdeveloper.org/news/14498</guid>
      <link>http://www.phpdeveloper.org/news/14498</link>
      <description><![CDATA[<p>
On the Ibuildings techPortal today they've posted the latest podcast recording from the 2009 Dutch PHP Conference sessions, <i>Paul Reinheimer</i>'s look at <a href="http://techportal.ibuildings.com/2010/05/11/state-ajax-how-to-maintain-browser-and-application-state-in-an-asynchronous-world/">maintaining state with Ajax</a> ("in an Asynchronous World").
</p>
<blockquote>
This talk will examine the two greatest problems in Ajax development (except for that pesky browser issue): Exactly what that "Asynchronous" word means, what problems it creates, and how they can be effectively managed, next the YUI Browser History object will be examined, finally handing control of Ajax applications back to the user via their familiar back button.
</blockquote>
<p>
You can listen to this new episode in one of two ways - either by using the <a href="http://techportal.ibuildings.com/2010/05/11/state-ajax-how-to-maintain-browser-and-application-state-in-an-asynchronous-world/">in-page player</a> or you can <a href="http://techportal.ibuildings.com/wp-content/uploads/audio/dpcradio/episode_010.mp3">download the mp3</a> directly.
</p>]]></description>
      <pubDate>Tue, 11 May 2010 12:38:37 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Padraic Brady's Blog: Mysteries Of Asynchronous Processing w/PHP - Pt 3: Spawned Child Processes]]></title>
      <guid>http://www.phpdeveloper.org/news/13319</guid>
      <link>http://www.phpdeveloper.org/news/13319</link>
      <description><![CDATA[<p>
<i>Padraic Brady</i> has posted <a href="http://blog.astrumfutura.com/archives/419-The-Mysteries-Of-Asynchronous-Processing-With-PHP-Part-3-Implementation-With-Spawned-Child-Processes-Using-Simple-Scripts-Or-Zend-Framework.html">part three</a> of his look at asynchronous processing in PHP applications today. The previous two parts <a href="http://www.phpdeveloper.org/news/13293">introduced</a> you to the topic and <a href="http://www.phpdeveloper.org/news/13306">got you ready</a> to work with child processes in a Zend Framework application. This latest part gets into the code showing how to fork the processes and handle communication between them.
</p>
<blockquote>
With the theory heavy portion of the series out of the way, we can begin to explore the various implementation possibilities. In this part, we will examine implementing Asynchronous Processing using a child process, i.e. a separate PHP process we create from our application during a request. We'll analyse this implementation option before introducing the source code so we may understand its advantages and disadvantages.
</blockquote>
<p>
He looks at both the advantages and disadvantages of processing with child processes and suggests a method to get a handle on the processes rather than just spawning new processes - forking. Some basic code examples are included, using the <a href="http://php.net/popen">popen</a> function to open the new child process and a Zend Framework example.
</p>]]></description>
      <pubDate>Thu, 01 Oct 2009 12:35:23 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Padraic Brady's Blog: The Mysteries Of Asynchronous Processing With PHP - Part 2 (CLI applications)]]></title>
      <guid>http://www.phpdeveloper.org/news/13306</guid>
      <link>http://www.phpdeveloper.org/news/13306</link>
      <description><![CDATA[<p>
In the <a href="http://blog.astrumfutura.com/archives/418-The-Mysteries-Of-Asynchronous-Processing-With-PHP-Part-2-Making-Zend-Framework-Applications-CLI-Accessible.html">second part</a> of his series looking at asynchronous processing in PHP applications, <i>Padraic Brady</i> lays the ground work for the third part and shows how to work with command line Zend Framework applications.
</p>
<blockquote>
Part 2 is a tangential detour into how to make a Zend Framework based application accessible from the command line before we delve into examples using this in future parts of the series. If you are not a Zend Framework user, I'm sure you can find relevant material online for your own preferred framework though the ZF pieces may still have some usefulness in understanding the approach from an MVC perspective.
</blockquote>
<p>
In his examples he skips over the basics of using a command line application and jumps right to things like argument handling, creating a custom router and making a custom "calling script" to handle the configuration of the CLI application.
</p>]]></description>
      <pubDate>Wed, 30 Sep 2009 08:32:01 -0500</pubDate>
    </item>
  </channel>
</rss>
