HelloController.php 800 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. /**
  3. * @link http://www.yiiframework.com/
  4. * @copyright Copyright (c) 2008 Yii Software LLC
  5. * @license http://www.yiiframework.com/license/
  6. */
  7. namespace app\commands;
  8. use yii\console\Controller;
  9. use yii\console\ExitCode;
  10. /**
  11. * This command echoes the first argument that you have entered.
  12. *
  13. * This command is provided as an example for you to learn how to create console commands.
  14. *
  15. * @author Qiang Xue <qiang.xue@gmail.com>
  16. * @since 2.0
  17. */
  18. class HelloController extends Controller
  19. {
  20. /**
  21. * This command echoes what you have entered as the message.
  22. * @param string $message the message to be echoed.
  23. * @return int Exit code
  24. */
  25. public function actionIndex($message = 'hello world')
  26. {
  27. echo $message . "\n";
  28. return ExitCode::OK;
  29. }
  30. }