Convenience method for starting a background task. Creates a new SystemTask instance in the repository and starts the process in the background.


SystemTask start_bg_task(repo $repo, $user, $title, collection $runnables, array $params = [], array $options = [])


  • repo - The repository instance to create the system task in.
  • user - The user invoking the task (NULL to use the authenticated repo user).
  • title - The title to assign to the task.
  • runnables - The non-empty collection of runnables to invoke.
  • params - An array of parameters to pass to the process. This must be an array of arrays whose top-level count equals the number of runnables to invoke.  Parameter array(s) must contain only primitive values (i.e. integer, float, boolean, string, or NULL).
  • options - An associative array where the key is any System Task Field Identifier and the value is the value to initialize the field to.  This is rarely used or specified because most fields are set automatically or by calling SystemTask methods after the task is created.


The instantiated SystemTask for the background process, or NULL if it could not be created.



use io_comand_systemtask\models\SystemTask;

$repo = comand::repo();
$runnables = $repo->get('FROM Runnable+ WHERE Identifier=?', [
    'bind' => ['RefreshCache']
$task = SystemTask::start_bg_task(
    'Refresh Cache',
    [['--mode', 'update']],
    ['Status' => 'Initializing...']
if($task === NULL) {
    comand::log_error('Could not start background process.');