├── README.md ├── index.php └── script.php /README.md: -------------------------------------------------------------------------------- 1 | A simple demo of running a scheduled PHP process on Heroku. 2 | 3 | 1. Clone this repo 4 | 5 | $ git clone https://github.com/ryanbrainard/php-scheduler-demo.git 6 | 7 | 2. Go in the dir 8 | 9 | $ cd php-scheduler-demo 10 | 11 | 3. Create the Heroku app with the buildpack set to a fork of the PHP buildpack that support the PHP CLI 12 | 13 | $ heroku create --buildpack https://github.com/ryanbrainard/heroku-buildpack-php.git 14 | 15 | 4. Push the code to Heroku 16 | 17 | $ git push heroku master 18 | 19 | 5. Test the script by running it in a one-off worker dyno just to see it work before scheduling it 20 | 21 | $ heroku run php www/script.php 22 | Running `php www/script.php` attached to terminal... up, run.6599 23 | Current time: 1359943709 24 | 25 | 6. Add the [Scheduler Add-on](https://devcenter.heroku.com/articles/scheduler) 26 | 27 | $ heroku addons:add scheduler:standard 28 | 29 | 7. Open the scheduler configuration page 30 | 31 | $ heroku addons:open scheduler 32 | 33 | 8. Add the script as a job. Same as one-off step above, but without the `heroku run` 34 | - Add job... 35 | - `$` `bin/php www/script.php` 36 | 37 | 9. View the scheduled job running in the logs 38 | 39 | $ heroku logs 40 | ... 41 | 2013-02-04T01:55:13+00:00 heroku[api]: Starting process with command `bin/php www/script.php` by scheduler@addons.heroku.com 42 | 2013-02-04T01:55:16+00:00 heroku[scheduler.4997]: Starting process with command `bin/php www/script.php` 43 | 2013-02-04T01:55:16+00:00 app[scheduler.4997]: Current time: 1359942916 44 | 2013-02-04T01:55:18+00:00 heroku[scheduler.4997]: Process exited with status 0 45 | 2013-02-04T01:55:18+00:00 heroku[scheduler.4997]: State changed from starting to complete 46 | ... 47 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | Hello, World!! 2 | -------------------------------------------------------------------------------- /script.php: -------------------------------------------------------------------------------- 1 | 2 | --------------------------------------------------------------------------------