每天laravel-20160717|Command-1
来源:互联网 发布:linux系统解压缩文件 编辑:程序博客网 时间:2024/05/01 02:07
namespace Illuminate\Console;use Illuminate\Contracts\Support\Arrayable;use Symfony\Component\Console\Helper\Table;use Symfony\Component\Console\Input\ArrayInput;use Symfony\Component\Console\Output\NullOutput;use Symfony\Component\Console\Question\Question;use Symfony\Component\Console\Input\InputInterface;use Symfony\Component\Console\Output\OutputInterface;use Symfony\Component\Console\Question\ChoiceQuestion;use Symfony\Component\Console\Formatter\OutputFormatterStyle;use Symfony\Component\Console\Command\Command as SymfonyCommand;// more namespaceclass Command extends SymfonyCommand{ /** * The Laravel application instance. * * @var \Illuminate\Contracts\Foundation\Application */ protected $laravel;// the big or base instance. /** * The input interface implementation. * * @var \Symfony\Component\Console\Input\InputInterface */ protected $input;// The input interface implementation. /** * The output interface implementation. * * @var \Illuminate\Console\OutputStyle */ protected $output;// The output interface implementation. /** * The name and signature of the console command. * * @var string */ protected $signature;// The name and signature of the console command ,like a token /** * The console command name. * * @var string */ protected $name;// command name,like a key /** * The console command description. * * @var string */ protected $description;// command description /** * The default verbosity of output commands. // the detail about the output commands. * verbosity == detail * @var int */ protected $verbosity = OutputInterface::VERBOSITY_NORMAL;// this is "32" /** * The mapping between human readable verbosity levels and Symfony's OutputInterface. * * @var array */ protected $verbosityMap = [ 'v' => OutputInterface::VERBOSITY_VERBOSE, 'vv' => OutputInterface::VERBOSITY_VERY_VERBOSE, 'vvv' => OutputInterface::VERBOSITY_DEBUG, 'quiet' => OutputInterface::VERBOSITY_QUIET, 'normal' => OutputInterface::VERBOSITY_NORMAL, ];// a array to change the flag to a human can read flag /** * Create a new console command instance. * * @return void */ public function __construct() { // We will go ahead and set the name, description, and parameters on console // commands just to make things a little easier on the developer. This is // so they don't have to all be manually specified in the constructors. if (isset($this->signature)) { $this->configureUsingFluentDefinition(); } else { parent::__construct($this->name); }// two way , one is configureUsingFluentDefinition // anther use father __construct $this->setDescription($this->description);// Set Description if (! isset($this->signature)) { $this->specifyParameters();// set the specify Parameters. } }// create a new console command instance // we will go ahead and set the name , description, and parameters on console commands to make a little easier on the developer. // This is so they don't have to all be manually specified in the constructors. /** * Configure the console command using a fluent definition. * * @return void */ protected function configureUsingFluentDefinition() { list($name, $arguments, $options) = Parser::parse($this->signature);// set the parser::parse(); parent::__construct($name);// use father __construct(); with a variable foreach ($arguments as $argument) { $this->getDefinition()->addArgument($argument); }// this is a addArgument ($argument) // set the argument foreach ($options as $option) { $this->getDefinition()->addOption($option); }// set the option }// configure the console command using a definition /** * Specify the arguments and options on the command. * * @return void */ protected function specifyParameters()// register arguments and options { // We will loop through all of the arguments and options for the command and // set them all on the base command instance. This specifies what can get // passed into these commands as "parameters" to control the execution. foreach ($this->getArguments() as $arguments) { call_user_func_array([$this, 'addArgument'], $arguments); }// call the argument function to add the argments foreach ($this->getOptions() as $options) { call_user_func_array([$this, 'addOption'], $options); }// call the addOption function to add the options }// send the right arguments and options to the command. // we will loop through all of the arguments and options for the command and set them all on the base command instance. // This specifies what can get passed into these commands as "parameters" to control the execution /** * Run the console command. * * @param \Symfony\Component\Console\Input\InputInterface $input * @param \Symfony\Component\Console\Output\OutputInterface $output * @return int */ public function run(InputInterface $input, OutputInterface $output) { $this->input = $input;// get input $this->output = new OutputStyle($input, $output);// get output return parent::run($input, $output);// use parent::run(); }// Run the console command. /** * Execute the console command. * * @param \Symfony\Component\Console\Input\InputInterface $input * @param \Symfony\Component\Console\Output\OutputInterface $output * @return mixed */ protected function execute(InputInterface $input, OutputInterface $output) { $method = method_exists($this, 'handle') ? 'handle' : 'fire';// check the way to start, return $this->laravel->call([$this, $method]);// never use the arguments }// a normal call the function, be ley mysql execute, // execute the console command.
0 0
- 每天laravel-20160717|Command-1
- 每天laravel-20160718|Command-2
- 每天laravel-20160725| Genaerator command-2
- 每天laravel-20160725| Genaerator command-3
- 每天laravel-20160726| Genaerator command-4
- 每天laravel-20160727| Genaerator command-5
- 每天laravel-20160728| Genaerator command-6
- 每天laravel-20160630|Repository -1
- 每天laravel-20160721|Application-1
- 每天laravel-20160821|CookieJar-1
- 每天laravel
- [李景山php]每天laravel[036]-laravel 系统服务 --- 认证-1
- [李景山php]每天laravel[038]-laravel 系统服务 --- 授权-1
- 每天laravel-20160724|abstract Genaerator-1
- [李景山php]每天laravel-20160827|McryptEncrypter-1
- [李景山php]每天laravel-20160901|Dispatcher-1
- [李景山php]每天laravel-20160910|Filesystem-1
- [李景山php]每天laravel-20160914|FileSystemManager-1
- leetCode 145:Binary Tree Postorder Traversal
- iOS _MJRefresh 导入最新Xcode 报错 解决方法
- Url转图片
- php简单的分页原理
- CoreGraphics CGPath(路径)
- 每天laravel-20160717|Command-1
- stringByAppendingPathExtension拼接路径
- Centos 6.5 编译安装Nginx+php+Mysql
- 获取路径的最后一个文件名lastPathComponent
- 二叉树的中序遍历
- C++中STL库中的assign函数
- 沉浸式状态栏Immersive Mode & 透明式状态栏Translucent Bars
- Oracle-33-变量%type、变量%rowtype、记录类型、记录表类型
- 获取文件的属性,时间等等