PHP code example of junty / junty-taskrunner

1. Go to this page and download the library: Download junty/junty-taskrunner 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/ */

    

junty / junty-taskrunner example snippets



Junty\TaskRunner\Runner\Runner;

$runner = new Runner();

$runner->task('say_hello', function () {
    echo 'hello!'; 
});

$runner->my_task_2 = function () {
    // ...
};

$runner->group('tests', function () {
    $this->task('tests_for_users', function () {
        // ...
    });

    $this->task('tests_for_admins', function () {
        // ...
    });
});

$runner->run(); // Runs all registred tasks

$runner->task('my_task', function () {});

// or

$runner->task(new MyTask());

$runner->group('my_group', function () {
    $this->task('my_task_from_group_1', function () {});

    // Another tasks
});

$runner->order('my_group', 'my_task', 'my_group_2');

$runner->run();

$runner->runTask('my_registred_task');

// or

$runner->runTask(new MyTask());

$runner->runGroup('my_registred_group');

// or

use Junty\TaskRunner\Task\Group;

$runner->runGroup(new class() extends Group
{
    public function __construct()
    {
    }

    public function getName() : string
    {
        return 'my_group';
    }

    public function task($task, callable $task = null)
    {
    }

    public function getTasks() : TaskCollection
    {
        $collection = new TaskCollection();

        $collection->set(new MyTask());
        $collection->set(new MyOtherTask());

        return $collection;
    }
});