1. Go to this page and download the library: Download danibrutal/forker library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
danibrutal / forker example snippets
/**************************************************
* Example: Retrieving the city-weather using external api
* Usage : php examples/demo.api.weather.php
* Storage: File
**************************************************/
london' => sprintf($urlApiWeather, 'London'),
'new-york' => sprintf($urlApiWeather, 'NewYork'),
'barcelona' => sprintf($urlApiWeather, 'barcelona'),
'lisboa' => sprintf($urlApiWeather, 'lisboa'),
'iasi' => sprintf($urlApiWeather, 'iasi'),
);
// a way to keep our data
$storageSystem = new FileStorage;
$numberOfSubTasks = 6;
$forker = new Forker($storageSystem, $myTasks, $numberOfSubTasks);
$forker->fork(function($city, $url, $emit) {
echo "Retrieving weather in $city\n";
$contents = file_get_contents($url);
$emit($city, $contents);
});
$allCitiesWeather = $forker->fetch();
var_dump($allCitiesWeather);
/**
* @param key
* @param value
* @return bool
*/
public function store($key, $value);
/**
* @param key
* @return value | false
*/
public function get($key);
/**
* @return array $tasks
*/
public function getStoredTasks();
/**
* @return bool
*/
public function cleanUp();
use Forker\Storage\ArrayStorage;
orageTest
{
protected function getSystemStorage()
{
return new ArrayStorage();
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.