Pak Jiddat - Innovative Software Services

Read: In the name of thy Lord Who createth, Createth man from a clot. Read: And thy Lord is the Most Bounteous, Who teacheth by the pen, Teacheth man that which he knew not. Nay, but verily man is rebellious That he thinketh himself independent!. Lo! unto thy Lord is the return. (Sura Alalaq 96:8)

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.

Related Articles

  1. Managing Php scripts using the Pak Php Framework Admin Tool
  2. Developing WordPress plugins using Pak Php framework - Part 2
  3. How to test Pak Php applications
  4. Pak Php framework
  5. Developing WordPress plugins using Pak Php framework - Part 1
  6. Developing your own Php Utilities Framework