1. Go to this page and download the library: Download long-running/core 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/ */
final class MyCleaner implements \LongRunning\Core\Cleaner
{
public function cleanUp() : void
{
echo "Cleaning up memory!";
}
}
$cleaner = new \LongRunning\Core\DelegatingCleaner([
new MyCleaner(),
]);
while (true) {
// Do heavy work, like processing jobs from a queue
echo "Doing heavy work";
sleep(1);
echo "Done with heavy work";
// Cleanup things
$cleaner->cleanUp();
}
namespace App;
use LongRunning\Core\Cleaner;
final class Worker
{
private Cleaner $cleaner;
public function __construct(Cleaner $cleaner)
{
$this->cleaner = $cleaner;
}
public function doWork() : void
{
while (true) {
// Do heavy work, like processing jobs from a queue
echo "Doing heavy work";
sleep(1);
echo "Done with heavy work";
// Cleanup things
$this->cleaner->cleanUp();
}
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.