Namespace illuminate\console;use illuminate\contracts\events\dispatcher;use illuminate\ Contracts\container\container;use symfony\component\console\input\arrayinput;use symfony\component\ Console\input\inputoption;use symfony\component\console\output\bufferedoutput;use symfony\component\ Console\application as symfonyapplication;use symfony\component\console\command\command as symfonycommand;use illuminate\contracts\console\application as applicationcontract;// my name spaceclass Application extends SymfonyApplication implements applicationcontract{// class application extends symfonyapplication implements applicationcontract /** * the laravel application instance. * * @var \ Illuminate\contracts\container\container */ protected $laravel;// The laravel application instance. // all use this instance in the /** * the output from the previous command. * * @var \symfony\ component\console\output\bufferedoutput */ protected $lastOutput;//the output from the previous command.// the previous Command output string. /** * create a new Artisan console application. * * @param \Illuminate\Contracts\Container\Container $laravel * @param \illuminate\contracts\events\dispatcher $events * @param string $version * @return void */ public function __construct (Container $laravel, Dispatcher $events, $version) { parent::__construct (' laravel framework ', $version);// use parents construct , may like set $this->laravel = $laravel;// set the instance the laravel $this->setautoexit (false);// set the auto exit $this->setcatchexceptions (false);//set catch exceptions &nbSP; $events->fire (New events\artisanstarting ($this));//fire the events \artisan Starting }// create a new artisan console application /** * Run an Artisan console command by name. * * @param string $command * @param array $ parameters * @return int */ // run an artisan console command by name. public Function call ($command, array $parameters = [])//run an artisan console command by name. {// call $command array $ Parameters $parameters = collect ($parameters)->prepend ($command);// collect ($parameters) ->prepend ($command) // set the parameters ,format the parameters. // set parameter $this->lastoutput = new bufferedoutput;// $this- >lastOutput get the new Buffered Output // the Output string is a Output class // set the lastOutput $this Setcatchexceptions (False);// set catch exceptions // Set catch exceptions // set the exceptions $result = $this->run (New arrayinput ($parameters->toarray ()), $ This->lastoutput);// run () // run the function use parameters and Output. $this Setcatchexceptions (True);// set the set catch exception return $result;// back the result to the call } /** * get the output for the last run command. * * @return string */ public function output () { return $this->lastoutput ? $this->laStoutput->fetch () : '; }// get the output for the last run command. // return $this->lastoutput ? $ This->lastoutput->fetch ():
This article is from the "Focus on PHP" blog, please be sure to keep this source http://jingshanls.blog.51cto.com/3357095/1765638
Daily laravel-20160721| Application-1