PHP delayable / parallel loading library (prefetching without prefetching)
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
delayable
example
LICENSE
README
example_common.php
example_curl.php

README

The PHP Delayable framework allows for delayed instantiation/retrieval of page content via proxy objects. Objects which implement the "Delayable" interface will have their method calls delayed until a render operation or blocking operation is called on them (a foreach or __toString call). Examples:

------------------------------------------------------

/**
CURL Example (example_curl.php):

curl providers built-in functions for running parallel http requests through it's PHP library. Using 
curl_multi_add_handle, curl_multi_exec, and curl_multi_getcontent, the developer can request multiple
urls from curl at the same time and retrieve the results at the speed of the slowest request (as
opposed to the speed of all requests combined). The \example\UrlLoader class abstracts this work out
in the loadDelayed method and the Delayable framework will run all the calls in parallel as soon as 
the results are needed (when the echo is called in this example).
**/

require("example_common.php");

$urlLoader = delay( new \example\UrlLoader() );
$google = $urlLoader->get("http://www.google.com");
$yahoo = $urlLoader->get("http://www.yahoo.com");
$bing = $urlLoader->get("http://www.bing.com");

echo $google.$yahoo.$bing;