If you are looking for DotKernel 3 related posts, go here.
Starting with 1.5, DotKernel has a Console bootstrap to easily run PHP scripts from the command line. The most common use for this is to be able to run cron jobs without using wget and going through Apache.
The bootstrap can be found in Console/index.php and it has one controller in Controller.php with two example actions.
Currently there are two command line arguments:
- -a [action] – the name of the action that will be executed
- -e [environment] – the environment, as defined in application.ini. Possible values are development, staging and production. This argument is optional, it defaults to production
Any other arguments set when calling the script will be available in the controller in the $registry->arguments array.
The controller bundled with DotKernel has two example actions, “count-users” which demonstrates how to interact with models, and “send-newsletter” which reads the newsletter from the command line.
/var/www/vhosts/example.com/httpdocs/Cron/index.php -e staging -a count-users
/var/www/vhosts/example.com/httpdocs/Cron/index.php -e staging -a send-newsletter "test newsletter"