添加新artisan命令并将命令作为计划任务运行时出现流明错误

时间:2018-04-20 12:12:37

标签: laravel command scheduled-tasks lumen artisan

在控制台/命令下添加一个文件ExampleCommand.php,这是根据laravel文档,

现在在console / kernal.php的protected命令部分中添加了新命令

protected $commands = [
            Commands\ExampleCommand::class,
        ];

当php artisan schedule:run命令被执行时,它会出现以下错误。

    lumen.ERROR: ReflectionException: Method App\Console\Commands\ExampleCommand::handle() does not exist in /var/www/html/busnet/Source/Main/Services/vendor/illuminate/container/BoundMethod.php:135
Stack trace:
#0 /var/www/html/busnet/Source/Main/Services/vendor/illuminate/container/BoundMethod.php(135): ReflectionMethod->__construct(Object(App\Console\Commands\ExampleCommand), 'handle')
#1 /var/www/html/busnet/Source/Main/Services/vendor/illuminate/container/BoundMethod.php(115): Illuminate\Container\BoundMethod::getCallReflector(Array)
#2 /var/www/html/busnet/Source/Main/Services/vendor/illuminate/container/BoundMethod.php(29): Illuminate\Container\BoundMethod::getMethodDependencies(Object(Laravel\Lumen\Application), Array, Array)
#3 /var/www/html/busnet/Source/Main/Services/vendor/illuminate/container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#4 /var/www/html/busnet/Source/Main/Services/vendor/illuminate/container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Laravel\Lumen\Application), Array, Object(Closure))
#5 /var/www/html/busnet/Source/Main/Services/vendor/illuminate/container/Container.php(549): Illuminate\Container\BoundMethod::call(Object(Laravel\Lumen\Application), Array, Array, NULL)
#6 /var/www/html/busnet/Source/Main/Services/vendor/illuminate/console/Command.php(183): Illuminate\Container\Container->call(Array)
#7 /var/www/html/busnet/Source/Main/Services/vendor/symfony/console/Command/Command.php(252): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#8 /var/www/html/busnet/Source/Main/Services/vendor/illuminate/console/Command.php(170): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#9 /var/www/html/busnet/Source/Main/Services/vendor/symfony/console/Application.php(946): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /var/www/html/busnet/Source/Main/Services/vendor/symfony/console/Application.php(248): Symfony\Component\Console\Application->doRunCommand(Object(App\Console\Commands\ExampleCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /var/www/html/busnet/Source/Main/Services/vendor/symfony/console/Application.php(148): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /var/www/html/busnet/Source/Main/Services/vendor/illuminate/console/Application.php(88): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /var/www/html/busnet/Source/Main/Services/vendor/laravel/lumen-framework/src/Console/Kernel.php(84): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /var/www/html/busnet/Source/Main/Services/artisan(35): Laravel\Lumen\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 {main}  

In BoundMethod.php line 135:

  Method App\Console\Commands\ExampleCommand::handle() does not exist 

任何人都可以帮我解决这个问题吗?

提前致谢

0 个答案:

没有答案