This post refers to DotKernel 1, based on Zend Framework 1.
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.

Usage

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.

Examples

/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"

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>