在控制台/命令下添加一个文件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
任何人都可以帮我解决这个问题吗?
提前致谢