jeudi 1 mars 2018

Creating an Artisan Command queue depending on previous Command's output

I have 3 different Artisan commands that I want to fire in succession inside one Artisan command depending on the previous command output. So if command_one is executed, only then command_two starts, etc.

Main Command

public function handle()
{
    $file = $this->argument('file');

    $command_one = Artisan::call('command:one', [
        'file' => $file
    ], $this->getOutput());

    if ($command_one == true) {
        $command_two = Artisan::call('command:two', [
            'file' => $file
        ], $this->getOutput());

        if ($command_two == true) {
            $command_three = Artisan::call('command:three');
        }
    }
}

Commands One, Two, Three

public function handle()
{
    if ($something == $something_else) {
        return true
    } else {
        return false
    }
}

Problem is, I cannot get the proper returns from commands one, two and tree into the main command. Every if I od dd(Artisan::call) it is always 0. Is there something I'm missing?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire