1. Go to this page and download the library: Download hemend/laravel-api 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/ */
shell
namespace App\Jobs;
use Hemend\Api\Interfaces\TrackableJob;
use Hemend\Api\Traits\TrackableQueue;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class TrackableTest implements ShouldQueue, TrackableJob
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, TrackableQueue;
/**
* Create a new job instance.
*/
public function __construct()
{
$this->prepareTracker();
}
/**
* Execute the job.
*/
public function handle(): void
{
$max = mt_rand(5, 30);
$this->setProgressMax($max);
for ($i = 0; $i <= $max; $i += 1) {
sleep(1); // Some Long Operations
$this->setProgressNow($i);
}
$this->setOutput(['total' => $max, 'other' => 'parameter']);
}
}
shell
use App\Jobs\TrackableTest;
TrackableTest::dispatch();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.