-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chris,

This is certainly possible.

The simplest way is actually outlined on Felix's site:
http://www.thinkingphp.org/2006/08/15/the-ultimate-cakephp-bootstrap-technique/

Based on what Felix describes in that post, I typically do the following:

<?php

$_GET['url'] = 'favicon.ico';
require_once('app'.DIRECTORY_SEPARATOR.'webroot'.DIRECTORY_SEPARATOR.'index.php');
loadController(null);

?>

That gets cake included into your script.  From there you would require
and instantiate your Controller, and go about business as usual, making
sure that you're not depending on data being passed as it would in a web
app, unless you are going to set $_GET and $_POST appropriately
yourself, or manually pass input to your Controller action invocations.

For instance, here's a snippet of how I use CakePHP inside of phing to
handle some build tasks that actually live inside of a Controller.  Note
that init_acl and init_auth are the names of the actions/methods defined
in my BuildController (and I store BuildController in my app/vendors
directory rather than app/controllers):

    <target name="include_cake">
        <php expression="
            define('DEBUG', 0);
            $_GET['url'] = 'favicon.ico';
require_once('app'.DIRECTORY_SEPARATOR.'webroot'.DIRECTORY_SEPARATOR.'index.php');
            loadController(null);
        "/>
    </target>

    <target name="inst_bc" depends="include_cake">
        <php expression="
            vendor('build_controller');
        "/>
    </target>

    <target name="init_acl" depends="inst_bc">
        <php expression="
            $build_controller = new BuildController();
            $build_controller->_initComponents();
            $build_controller->constructClasses();
            $build_controller->beforeFilter();
            $build_controller->init_acl();
        "/>
    </target>

    <target name="init_auth" depends="inst_bc">
        <php expression="
            $build_controller = new BuildController();
            $build_controller->_initComponents();
            $build_controller->constructClasses();
            $build_controller->beforeFilter();
            $build_controller->init_auth();
        "/>
    </target>

Darian

Chris Hartjes wrote:
> I've been using Felix's awesome Google Analytics model to create some
> reports on the forum sites my employer owns.  However, I'm wondering
> if it's even possible to create a CakePHP app that can be run as a CLI
> app as a cron job...
> 
> Any thoughts on how to accomplish this?
> 

- --
Darian Anthony Patrick <[EMAIL PROTECTED]>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFbwifKpzEXPWA4IcRAgOoAJ49XST2GVKn7VjvKJV7tCHNLET4wgCghiTj
iI68aRvCtQm6MZwVygo9YoI=
=Drkp
-----END PGP SIGNATURE-----

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Cake PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to