LoginSignup
0
0

More than 3 years have passed since last update.

LaravelのKernel.phpのscheduleメソッド内でcommandを使ってハマった件

Posted at

PHPとLaravelのバージョン

  • Laravel Framework 5.7.28
  • PHP 7.3.11

出ていたエラー

ERROR: Aborted. {"exception":"[object] (Symfony\\Component\\Console\\Exception\\RuntimeException(code: 0): Aborted. at /home/hoge/hoge/hoge_api/vendor/symfony/console/Helper/QuestionHelper.php:135)
 {"exception":"[object] (Symfony\\Component\\Console\\Exception\\CommandNotFoundException(code: 0): Command \"hoge\" is not defined.

書いていたコード

app/Console/Kernal.php

    protected function schedule(Schedule $schedule)
    {
        $schedule->command('hoge')->cron('* * * * *');
    }

app/Console/Commands/Hoge.php

   /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'command:hoge';

解決策

下記が叩かれていてそんなものないよ、と怒られていたので

'/usr/bin/php' 'artisan' hoge 

command:を付ける

    protected function schedule(Schedule $schedule)
    {
        $schedule->command('command:hoge')->cron('* * * * *');
    }

そうすると下記が叩かれるようになります。

'/usr/bin/php' 'artisan' command:hoge
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0