2013-07-24 39 views
19

Tôi không thực sự chắc chắn về mức độ thuật ngữ này tồn tại, nhưng trong php-framework Laravel có một công cụ dòng lệnh gọi là Artisan đang được sử dụng để tạo cronjobs. (aka lệnh) Khi bạn tạo một lệnh. Bạn có thể chỉ định đối số VÀ tùy chọn như sau:Sự khác biệt giữa các đối số và tùy chọn là gì?

/** 
* Get the console command arguments. 
* 
* @return array 
*/ 
protected function getArguments() 
{ 
    return array(
     array('example', InputArgument::REQUIRED, 'An example argument.'), 
    ); 
} 

/** 
    * Get the console command options. 
    * 
    * @return array 
    */ 
    protected function getOptions() 
    { 
     return array(
      array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null), 
     ); 
    } 

Sự khác biệt giữa hai loại là gì?

+0

Lol Tôi chỉ đọc câu hỏi cũ của riêng mình như "Sự khác biệt giữa các đối số và ý kiến". Philosofical thực sự. – Himmators

Trả lời

22

Hãy nhìn vào các artisan migrate:make giúp đỡ:

Usage: 
migrate:make [--bench[="..."]] [--create] [--package[="..."]] [--path[="..."]] [--table[="..."]] name 

Arguments: 
name     The name of the migration 

Options: 
--bench    The workbench the migration belongs to. 
--create    The table needs to be created. 
--package    The package the migration belongs to. 
--path    Where to store the migration. 
--table    The table to migrate. 
--help (-h)   Display this help message. 
--quiet (-q)   Do not output any message. 
--verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug 
--version (-V)  Display this application version. 
--ansi    Force ANSI output. 
--no-ansi    Disable ANSI output. 
--no-interaction (-n) Do not ask any interactive question. 
--env     The environment the command should run under. 

Argument is cái gì đó bạn thường cần phải cung cấp ít nhất một, trong trường hợp này bạn cần phải cung cấp tên di cư hoặc lệnh sẽ nâng cao một lỗi.

Tùy chọn, rõ ràng là tùy chọn, một cái gì đó mà bạn sử dụng để sửa đổi hành vi lệnh.