Hi!
First I'd like to thank you for your great job in maintaining this module :)
I have a question/problem - is it possible to declare schedule task in module? Is there any good practice for that or should I just check in my main applications app/Console/Kernel.php file that the module is present and declare task there?
Hi,
You can do it in the module itself. Just use the $this->commands() inside your service provider.
Ok, I understand that I can register my commands there like
private function registerCommands()
{
$this->commands([
MyCommand::class
]);
}
but what about scheduling them? Is there Schedule class instance available from there (or can I make it available)? Sorry for my silly questions, but obviosly I have a lot to learn about laravel...
I found some solution here - http://stackoverflow.com/questions/30456737/how-to-schedule-artisan-commands-in-a-package , I think I'll give it a try later, thank you for pointing me at that direction ;) I consider this issue as closed.
Greetings.
After reading a lot, the solution on @pawlox last comment, does Schedule the command, running the artisan command php artisan:schedule run, returns something like this Running scheduled command: '/Applications/XAMPP/xamppfiles/bin/php-7.0.13' 'artisan' stores:stores-off > '/dev/null' 2>&1. Seems pretty good to me.
I got another Lavavel 5.4 Project running without this package, and the commands (with the schedules) uses a handle method on Command, and the Kernel calls it with the schedule method on the Kernel File
The template for the Command file on the Module, change the handle method to a fire method, is that correct? Im unable to make it work, even with the orginal method name i cant run it correctly.
Theres any clue or help, advice, or something that you can discuss with me? @nWidart.
Thanks for your time
Most helpful comment
I found some solution here - http://stackoverflow.com/questions/30456737/how-to-schedule-artisan-commands-in-a-package , I think I'll give it a try later, thank you for pointing me at that direction ;) I consider this issue as closed.