I working currently on a simple Reminder Laravel app for Heroku. I've written my API and everything works well. Now I want to run a scheduled task on Heroku.
Basically I'm looking for something to execute the following command on a separate dyno:
php EmailScheduler.php
or
php artisan schedule:emails
This command should be a long running process where e.g. each minute the same task is being executed over and over.
In this task I want to query my database and get all reminders that are due and send them as an email so I have to be able to access the business logic of my application like eloquent models.
I know about the scheduler add-on or about certain "cron" solutions but I would like a PHP only solution so just a long running script or task that might sleep most of the time and wake up each minute or so.
In Ruby (Rails) for example I could require the environment, thereby have access to my business logic and then fire up a timer task using the concurrent-ruby library.
I already tried to require the
bootstrap/autoload.php
bootstrap/app.php
files but it seems like I have to do more than just this, like boot the application.
How can I solve this using the Laravel framework and possibly other third-party libraries ?