每天laravel-20160721|Application-1


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 space
class 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

        $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():
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值