1. Go to this page and download the library: Download dmamontov/asynctask-7 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/ */
dmamontov / asynctask-7 example snippets
use AsyncTask\{
AsyncTask,
Collection
};
class TestTask extends AsyncTask
{
protected function onPreExecute(Collection $collection)
{
}
protected function doInBackground(Collection $collection)
{
return 'My First Task';
}
protected function onPostExecute($result)
{
echo $result;
}
protected function publishProgress()
{
echo rand(0,9) . PHP_EOL;
}
}
$task = new TestTask();
$task
->setTitle('TestTask')
->execute(new Collection);
use AsyncTask\AsyncTask;
use AsyncTask\Collection;
class ExampleTask extends AsyncTask
{
/**
* Optional method.
*/
protected function onPreExecute(Collection $collection)
{
return $collection;
}
/**
* Required method.
*/
protected function doInBackground(Collection $collection)
{
return $collection;
}
/**
* Optional method.
* With this method, an additional process is created.
*/
protected function publishProgress()
{
}
/**
* Optional method.
*/
protected function onPostExecute($result)
{
}
/**
* Optional method.
*/
protected function onCancelled()
{
}
}
use AsyncTask\Adapter;
use AsyncTask\Interfaces\AdapterInterface;
class ExampleAdapter extends Adapter implements AdapterInterface
{
/**
* Required method.
*/
public function init(): AdapterInterface
{
return $this;
}
/**
* Required method.
*/
public function finish(): AdapterInterface
{
return $this;
}
/**
* Required method.
*/
public function clean(bool $parent = false): AdapterInterface
{
return $this;
}
/**
* Required method.
*/
public function has($key, bool $parent = false): bool
{
return false;
}
/**
* Required method.
*/
public function remove($key, bool $parent = false): bool
{
return true;
}
/**
* Required method.
*/
public function get($key, bool $parent = false)
{
return null;
}
/**
* Required method.
*/
public function write($key, $val, bool $parent = false): AdapterInterface
{
return $this;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.