Writing command line scripts using Pak Php framework
Created On: 09 May, 2016: 14:12:57 - Tags : pak php framework
This article describes how to write command line scripts using the Pak Php framework. Suppose you have written a web application and you want to run it from the command line. For example as a cron job. Usually you will have to write a separate script that runs from the command line and uses the database of the web application. The Pak Php framework allows you to write web applications that can be easily run from the browser or from the command line. To run your Pak Php framework application from the command line you can use following command:
php index.php --module="WebExample" --option="run_cronjob_script"This will run the command run_cronjob_script in the webexample project. The handler for the run_cronjob_script command needs to be mentioned in the Configuration.php file in webexample project. Alternately you can just create a function called HandleRunCronJobScript in your application class file. This function is automatically called by the framework routing class. The application class file in the webexample project is called WebExample.php. To run the your web application as a cron job. You can simply add the above command to the crontab file.