PHP code example of paulhenri-l / laravel-task-runner

1. Go to this page and download the library: Download paulhenri-l/laravel-task-runner 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/ */

    

paulhenri-l / laravel-task-runner example snippets




class FakeCommand extends Illuminate\Console\Command
{
    use PaulhenriL\LaravelTaskRunner\CanRunTasks;

    protected $signature = 'my-command';

    /**
     * Execute the console command.
     */
    public function handle()
    {
        $this->runTasks([
            MyFirstTask::class,
            new MySecondTask()
        ]);

        $this->info('Installation done 🎉');
    }
}



use Illuminate\Console\Command;
use PaulhenriL\LaravelTaskRunner\TaskInterface;

class MyFirstTask implements TaskInterface
{
    public function __construct(SomeDependency $someDependency)
    {
        //
    }

    public function __invoke(Command $command)
    {
        $command->info('Hello from MyFirstTask.');
    }
}



use Illuminate\Console\Command;
use PaulhenriL\LaravelTaskRunner\TaskInterface;

class SomeTask implements TaskInterface
{
    public function __invoke(Command $command)
    {
        if ($thereIsAnError) {
            return false;
        }
    }
}