Running Zoop Page As Cron

In Zoop I have written a couple pages that would be useful to run as Cron jobs. How would I go about accessing the pages without making an HTTP request via Apache?

To help clear up what I am looking for I would like to setup the example. The page exists in a zone called reports and is named example. The page only generates a daily report that is saved on the server. There is no HTML output or required interaction. The page opens the database assembles some data then saves a file on the server. The fake page would look like "http://www.null.com/index.php/reports/example" if accessed from a browser.

One solution is to use PHP and create a file that will make a CURL call to the localhost and open the requested page. This will cause Zoop to load properly and the page to execute. This is not ideal because we are firing up network resources and a Web Server for something that does not require it. What if the report takes a minute to generate as the data grows over time? That would mean there is an Apache process waiting to finish a request for quite sometime when it could instead be serving data.

The other solution would be to have a PHP file called cron.php which would setup all the necessary variables that an Apache or other webserver request would generate then call index.php or zoop->zun(). Before I speculate anymore would this be the correct solution?

Calling Zoop pages

Off the top of my head, I see three approaches. I like the third.
First, try setting up the request information yourself, then run zoop requests as normal. Since I haven't done this, There may be other variables that need to be initialized, but this gives you an example of how to start out.

<?php
$_SERVER['PATH_INFO'] = '/reports/example';
include_once(dirname(__file__) . "/includes.php");
$zoop->run();
 
?>

- OR -
Try to make the request directly. This will work fine if you have no dependencies on zone_default in zone_example, i.e., zone_default::initZone() doesn't do anything that zone_example needs.
<?php
 
include_once(dirname(__file__) . "/includes.php");
$zone = &new zone_example();
$zone->handleRequest(array('example'));
//or maybe even
$zone->pageExample(array('pageParam1'), array('zoneParam1' => 'somevalue'));

- OR -
Take the functionality in the page function, encapsulate it in a separate function in misc.php, or wherever, have the page function call your new function, and let your cron job also call the function:
cron.php:
<?php
 
include_once(dirname(__file__) . "/includes.php");
exampleReportFunction();

zone_report.php:
<?php
 
class zone_report extends zone
{
    function pageExample()
    {
        exampleReportFunction();
        echo('done');
    }
}

misc.php:
<?php
function exampleReportFunction()
{
    //do a lot of work
}

john 13 Jul 2008

Example 2 I think will fit my needs

John,
First thanks for the reply. I think that example 2 fits my needs best as I have no dependencies on other zones, but I do need the variables that are set when the Zoop configuration files run as well as the message system. Under other conditions I can see where example 3 would work best.

To finalize the example I started I am going to be running a cron which will send out a follow up email 3 days after a purchase. The email is create in Zoop so the administrative tool can be used to manually resend the email if someone did not receive the email. Keeping it all in one place will allow me to write the email and all the setup for the email once, then access it with Cron or through the UI.

jmorant@cloud9l... 17 Jul 2008