rubenvanerk/laravel-parallel-console-tasks

Run tasks in parallel in console commands

0.1.1 2023-02-01 08:07 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A simple trait to run Laravel Zero-like tasks in parallel.

Installation

You can install the package via composer:

composer require rubenvanerk/laravel-parallel-console-tasks

Usage

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use RubenVanErk\LaravelParallelConsoleTasks\RunsParallelTasks;

class Tasks extends Command
{
    use RunsParallelTasks;
    
    // ...
    
    public function handle() {
    
        $this->tasks([
            'Task 1' => function () {
                // Do a thing
                return true;
            },
            'Task 2' => function () {
                // Do another thing in parallel
                return true;
            },
        ]);
        
    }
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.