tp 5シリーズ2カスタムコマンドライン(タイミングスクリプト)

2040 ワード

まずcommandを構成します.phpファイル、ディレクトリはアプリケーション/command.php

第二歩、コマンド類ファイルを作成し、アプリケーション/home/command/Testを新規作成する.php
setName('test')->setDescription('Here is the remark ');
    }

    protected function execute(Input $input, Output $output)
    {
        $output->writeln("TestCommand:");
    }
}

このファイルはtestというコマンドを定義し、Here is the remarkと注記し、実行コマンドはTestCommandを出力します.
ステップ3、テスト-コマンドヘルプ-コマンドラインで実行
php think

しゅつりょく
Think Console version 0.1

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display this help message
  -V, --version         Display this console version
  -q, --quiet           Do not output any message
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  build              Build Application Dirs
  clear              Clear runtime file
  help               Displays help for a command
  list               Lists commands
  test               Here is the remark 
 make
  make:controller    Create a new resource controller class
  make:model         Create a new model class
 optimize
  optimize:autoload  Optimizes PSR0 and PSR4 packages to be loaded with classmaps too, good for production.
  optimize:config    Build config and common file cache.
  optimize:route     Build route cache.
  optimize:schema    Build database schema cache.


ステップ4 testコマンドを実行
php think test

しゅつりょく
TestCommand: