是否可以或建议将 Laravel 命令分组到嵌套组中?

Is it possible or recommended to group Laravel commands into nested groups?

我们看到 Laravel 的 artisan 命令采用 <module>:<action> 的典型格式,所以有...

php artisan migrate:refresh
php artisan cache:clear
// etc.

第三方包在那里添加他们的供应商名称,所以我们得到...

php artisan l5-swagger:generate

虽然这可能适用于特定的包,但如果我想在项目名称和模块名称下命名我的应用程序的本机命令怎么办?大致是这样的:

php artisan myapp:auth:create-admin

相对于简单

php artisan myapp:create-admin
// OR
php artisan auth:create-admin

或者也许我想发疯并在其中也包含我的供应商名称:

php artisan myname:myapp:auth:create-admin

这是一个疯狂的例子,但简单的、额外的一级命名空间肯定会有助于组织命令并保持整洁。

有没有这样的命令?是否可以通过类似于分组路线的方式来做到这一点?

我想避免创建具有子命令的 "super command",例如:

php artisan myapp:command Auth CreateAdmin

以下是我的应用程序上可用的命令示例:

 ps4
  ps4:editor:create                       Create first data ThemeEditor in the database. Options : update | dump
  ps4:editor:export-css                   Export CSS
  ps4:editor:import-css                   Import CSS
  ps4:editor:import-value                 Create first data ThemeEditor in the database
  ps4:export:document                     Routine to generate static file base on release section of backoffice
  ps4:export:html                         Export Accessbility as html files in export.zip file : Requirement : You should put zip file on propal folder.
  ps4:generate                            Full document generation
  ps4:generate:blur:image                 Generate image blur for one document.
  ps4:generate:blur:zoom                  Regenerate all Zoom base64 blur
  ps4:generate:image                      Generate all images of your document
  ps4:generate:onepage                    generate concat of all html in one page
  ps4:generate:uglify                     Uglify generated html/assets to be spyproof
  ps4:generate:vocalization               Generate mp3 by page for a document
  ps4:import:documents                    Massive document Import
  ps4:import:html                         Import Accessbility content from html files
  ps4:import:vocalisation                 Import vocalisation files
  ps4:import:xml                          Import Accessbility content from xml file
  ps4:lunch-worker                        Lunch worker and check if they are alive
  ps4:media:image                         Post traitment media image
  ps4:media:video                         Post traitment media video
  ps4:migrate:accessibility-content       Migrate Accessibility to raw content
  ps4:monitoring:worker                   Command line to monitor our worker
  ps4:optimize:article                    Optimize image on article view.
  ps4:page:generate                       Full document generation
  ps4:page:reset-name                     Reset name of page per number page
  ps4:pdf:html                            Generate html files for specific document and specific pdf.
  ps4:pdf:image                           Convert pdf in images with different size, format, quality.
  ps4:pd:2txt                             Extract from pdf all text splitted by page.
  ps4:worker                              Spawn worker for image traitment

你的命令可以通过$signature属性配置:

namespace App\Console\Commands\Editor;

use Illuminate\Console\Command;

class CreateCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'ps4:editor:create {foo}';
}