aimeos / aimeos-docs

Aimeos documentation
https://aimeos.org/docs
18 stars 23 forks source link

Laravel Cronjobs #37

Open iammart opened 2 years ago

iammart commented 2 years ago

Would you consider an update to the documentation for managing cronjobs for Laravel installs?

This is based on my existing setup and the advice from the Laravel documentation.

Laravel's command scheduler allows you to fluently define your command schedule within your Laravel application itself and not within the cron entry itself.

I setup a single cronjob on the server that hits the scheduler every minute.

* * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1

In its most very basic form I will implement the schedule method on App\Console\Kernel, and schedule the commands to execute and and how often to repeat.

For eg.

The following command has a list of jobs that needs to be executed "every minute".

* * * * * php /path/to/artisan aimeos:jobs "order/export/csv order/email/delivery order/email/payment order/email/voucher order/service/delivery subscription/export/csv customer/email/account"

We can replace this with the schedule command which can be committed and managed through the repository.

protected function schedule(Schedule $schedule) 
{
    $schedule->command($this->buildCommand('aimeos:jobs', [
        'order/export/csv',
        'order/email/delivery',
        ...
        'customer/email/account'
    ]))->everyMinute();
}

Similarly, those jobs that need to run every hour...


protected function schedule(Schedule $schedule) 
{
    $schedule->command($this->buildCommand('aimeos:jobs', [
        'customer/email/watch',
        ...
        'order/service/payment',
    ]))->hourly();
} 

There may be a reason why you haven't taken this approach that im unaware off, only I did notice that the TYPO3 is managed differently to Symphony and Laravel setups so its not necessarily for consistency across the supported platforms.

If you are happy with the suggestion I can fork the repo and create a pull request with my amendments?

aimeos commented 2 years ago

Yes, if you can create a PR how to configure scheduler task in Laravel, we will happy to merge it into the docs :-)