1. Go to this page and download the library: Download react/partial 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/ */
react / partial example snippets
public function handleDownload($filename)
{
$this->downloadFile($filename, ...);
}
public function downloadFile($filename, $callback)
{
$contents = get the darn file asynchronously...
$callback($contents);
}
public function processDownloadResult($filename, $contents)
{
echo "The file $filename contained a shitload of stuff:\n";
echo $contents;
}
public function handleDownload($filename)
{
$this->downloadFile($filename, function ($contents) use ($filename) {
$this->processDownloadResult($filename, $contents);
});
}
use function React\Partial\bind;
public function handleDownload($filename)
{
$this->downloadFile($filename, bind([$this, 'processDownloadResult'], $filename));
}
use function React\Partial\bind;
$add = function ($a, $b) {
return $a + $b;
};
$addOne = bind($add, 1);
echo sprintf("%d\n", $addOne(5));
// outputs 6