每天laravel-20160718|Command-2
来源:互联网 发布:linux报错e45 编辑:程序博客网 时间:2024/05/22 08:09
// 2016-04-15 /** * Call another console command. * * @param string $command * @param array $arguments * @return int */ public function call($command, array $arguments = []) { $instance = $this->getApplication()->find($command);// get the find($command) // a instance $arguments['command'] = $command;// save the command to the $arguments. return $instance->run(new ArrayInput($arguments), $this->output);// $instance->run }// Call another console command // a ArrayInput $this->output // ArrayInput($argument),$this->output; // ArrayInput($argument), change the command array to a new array. /** * Call another console command silently. * * @param string $command * @param array $arguments * @return int */ public function callSilent($command, array $arguments = [])//call Silent function { $instance = $this->getApplication()->find($command);// get command instance $arguments['command'] = $command;// $arguments return $instance->run(new ArrayInput($arguments), new NullOutput);// no outPut }// call another console command silently /** * Get the value of a command argument. * * @param string $key * @return string|array */ public function argument($key = null) { if (is_null($key)) { return $this->input->getArguments(); }// all argument to send back return $this->input->getArgument($key);// get you want value by you key }// Get the value of a command argument. /** * Get the value of a command option. * * @param string $key * @return string|array */ public function option($key = null) { if (is_null($key)) { return $this->input->getOptions(); }// $this->input->getOptions(); return $this->input->getOption($key);// get the getOption by key }// Get the value of a command option /** * Confirm a question with the user. * * @param string $question * @param bool $default * @return bool */ public function confirm($question, $default = false) {// use api function to check the question return $this->output->confirm($question, $default); }// Confirm a question with the user. /** * Prompt the user for input. * * @param string $question * @param string $default * @return string */ public function ask($question, $default = null) { return $this->output->ask($question, $default); }// Prompt the user for input. // use the /** * Prompt the user for input with auto completion. * * @param string $question * @param array $choices * @param string $default * @return string */ public function anticipate($question, array $choices, $default = null) { return $this->askWithCompletion($question, $choices, $default);// askWithCompletion }// Prompt the user for input with auto completion /** * Prompt the user for input with auto completion. * * @param string $question * @param array $choices * @param string $default * @return string */ public function askWithCompletion($question, array $choices, $default = null) { $question = new Question($question, $default);// get a question $question->setAutocompleterValues($choices);//api function return $this->output->askQuestion($question);//api function }//Prompt the user for input with auto completion /** * Prompt the user for input but hide the answer from the console. * * @param string $question * @param bool $fallback * @return string */ public function secret($question, $fallback = true) { $question = new Question($question); $question->setHidden(true)->setHiddenFallback($fallback); return $this->output->askQuestion($question); }//Prompt the user for input but hide the answer from the console. /** * Give the user a single choice from an array of answers. * * @param string $question * @param array $choices * @param string $default * @param mixed $attempts * @param bool $multiple * @return string */ public function choice($question, array $choices, $default = null, $attempts = null, $multiple = null) { $question = new ChoiceQuestion($question, $choices, $default); $question->setMaxAttempts($attempts)->setMultiselect($multiple); return $this->output->askQuestion($question); }// Give the user a single choice from an array of answers. /** * Format input to textual table. * * @param array $headers * @param \Illuminate\Contracts\Support\Arrayable|array $rows * @param string $style * @return void */ public function table(array $headers, $rows, $style = 'default') { $table = new Table($this->output);// get the Table instance if ($rows instanceof Arrayable) { $rows = $rows->toArray(); }// $table->setHeaders($headers)->setRows($rows)->setStyle($style)->render(); }// Format input to textual table. // use a class mode /** * Write a string as information output. * * @param string $string * @param null|int|string $verbosity * @return void */ public function info($string, $verbosity = null) { $this->line($string, 'info', $verbosity);//line the info }// Write a string as information output. /** * Write a string as standard output. * * @param string $string * @param string $style * @param null|int|string $verbosity * @return void */ public function line($string, $style = null, $verbosity = null) { $styled = $style ? "<$style>$string</$style>" : $string;// set the string $this->output->writeln($styled, $this->parseVerbosity($verbosity));// use a writeln }// Write a string as standard output // writeln /** * Write a string as comment output. * * @param string $string * @param null|int|string $verbosity * @return void */ public function comment($string, $verbosity = null) { $this->line($string, 'comment', $verbosity);// line comment // Write a string as comment output. }// Write a string as comment output. /** * Write a string as question output. * * @param string $string * @param null|int|string $verbosity * @return void */ public function question($string, $verbosity = null) { $this->line($string, 'question', $verbosity);// line() }// Write a string as question output. /** * Write a string as error output. * * @param string $string * @param null|int|string $verbosity * @return void */ public function error($string, $verbosity = null) { $this->line($string, 'error', $verbosity);// line() write a line }// Write a string as error output. /** * Write a string as warning output. * * @param string $string * @param null|int|string $verbosity * @return void */ public function warn($string, $verbosity = null) { if (! $this->output->getFormatter()->hasStyle('warning')) { $style = new OutputFormatterStyle('yellow');// new OutputFormatterStyle $this->output->getFormatter()->setStyle('warning', $style);// has the warning } $this->line($string, 'warning', $verbosity); }//Write a string as warning output. /** * Get the verbosity level in terms of Symfony's OutputInterface level. * * @param string|int $level * @return int */ protected function parseVerbosity($level = null) { if (isset($this->verbosityMap[$level])) { $level = $this->verbosityMap[$level];// $level } elseif (! is_int($level)) { $level = $this->verbosity;// the verbosity } return $level; }//Get the verbosity level terms of Symfony's OutputInterface level. /** * Set the verbosity level. * * @param string|int $level * @return void */ protected function setVerbosity($level) { $this->verbosity = $this->parseVerbosity($level);// verbosity }// Set the verbosity level. /** * Get the console command arguments. * * @return array */ protected function getArguments() { return [];// a empty array(); }// Get the console command arguments. /** * Get the console command options. * * @return array */ protected function getOptions() { return [];// a empty array(); }// Get the console command options. /** * Get the output implementation. * * @return \Symfony\Component\Console\Output\OutputInterface */ public function getOutput() { return $this->output;// a empty array(); }//Get the output implementation. /** * Get the Laravel application instance. * * @return \Illuminate\Contracts\Foundation\Application */ public function getLaravel() { return $this->laravel; }//Get the laravel application instance. // return the laravel /** * Set the Laravel application instance. * * @param \Illuminate\Contracts\Container\Container $laravel * @return void */ public function setLaravel($laravel) { $this->laravel = $laravel;//Set the laravel }// Set the laravel application instance.}
0 0
- 每天laravel-20160718|Command-2
- 每天laravel-20160725| Genaerator command-2
- 每天laravel-20160717|Command-1
- 每天laravel-20160725| Genaerator command-3
- 每天laravel-20160726| Genaerator command-4
- 每天laravel-20160727| Genaerator command-5
- 每天laravel-20160728| Genaerator command-6
- 每天laravel-20160711|Event-2
- 每天laravel-20160722|Application-2
- 每天laravel-20160730| Container -2
- 每天laravel-20160822|CookieJar-2
- 每天laravel
- [李景山php]每天laravel-20160828|McryptEncrypter-2
- [李景山php]每天laravel-20160902|Dispatcher-2
- [李景山php]每天laravel-20160911|FileSystem-2
- [李景山php]每天laravel-20160915|FileSystemManager-2
- [李景山php]每天laravel-20160920|Writer-2
- 每天laravel-20160620|MemcachedConnector
- rank() over,dense_rank() over,row_number() over函数的区别
- Android File操作-this.openFileOutput()的NullPointerException
- render和redirect_to区别
- javascript 从定义到执行,你不知道的那些事
- VirtualBox安装CentOS联网问题
- 每天laravel-20160718|Command-2
- 数据结构与算法分析-c语言描述版 mark allen weiss
- 读书笔记---操作系统概论
- Android中刷新列表
- ERROR:格式化hdfs后,datanode只启动了一个
- Spring请求参数为一个数组
- 编写一个程序,将小于n的所有质数找出来。
- [spoj11482]Count on a trie 解题报告
- leetcode 8 atoi