PHP code example of ibrostudio / laravel-artisan-command-pool

1. Go to this page and download the library: Download ibrostudio/laravel-artisan-command-pool 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/ */

    

ibrostudio / laravel-artisan-command-pool example snippets


use IBroStudio\CommandPool\CommandPool;

CommandPool::pool([
    Command1::class,
    Command2::class,
])->run()

use IBroStudio\CommandPool\CommandPool;

CommandPool::pool([
    Command1::class,
    Command2::class,
])->runWith(['name' => 'Name'])

use IBroStudio\CommandPool\CommandPool;

CommandPool::pool([
    Command1::class => ['name' => 'Name'],
    Command2::class => ['title' => 'Title'],
])->run()

use IBroStudio\CommandPool\CommandPool;

CommandPool::pool([
    Command1::class,
    Command2::class => ['title' => 'Title'],
])->runWith(['name' => 'Name'])

use IBroStudio\CommandPool\Concerns\HasCommandPool;

class MyContractorCommand extends Command
{
    use HasCommandPool;

    public function handle(): int
    {
        return $this->commandPool([
            Command1::class,
            Command2::class,
        ])->run();

        //or
        return $this->commandPool([
            Command1::class,
            Command2::class => ['title' => 'tata'],
        ])->runWith(['name' => $this->argument('name')]);
    }

use IBroStudio\CommandPool\CommandPool;

CommandPool::pool([
    Command1::class => ['runIf' => fn (): bool => false],
    Command2::class,
])->run() // will run only Command2