mardi 21 août 2018

Laravel, get the returned value from call method

I'm writting some custom commands for laravel and I need to get the returned value from one command called from the other, for example:

class One extends Illuminate\Console\Command
{
  protected $signature = 'cmd:one';

  public function handle()
  {
    // call 'Two' and uses the api information to continue
    $returnedValue = $this->call('cmd:two');

    dd($returnedValue) // int(1) ?? it seems to show exit code
  }
}



class Two extends Illuminate\Console\Command
{
  protected $signature = 'cmd:two';

  public function handle()
  {
    // this command retrieves some api information needed to continue
    return $infoFromAPI;
  }
}

I also tried calling statically Artisan::call(...) with the same result.

I know there is an $output property but doc is not clear about how use it.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire