I found this problem too, when I was sending emails using a cron job, and 
needed to link back to the site. However there is an easy workaround.

I am using the EmailTask from the Bakery, and added importing the router and 
routes definitions in here.

<?php
App::import('Core', 'Controller');
App::import('Component', 'Email');

App::import('Core', 'Router');
config('routes');

class EmailTask extends Shell {
...


and then in my bootstrap.php I add this:


/** CONFIG FOR CLI/SHELLS**/

if (empty($_SERVER['HTTP_HOST'])) {
 $_SERVER['HTTP_HOST'] = 'mydomain.com';
}

if (empty($_SERVER['HTTPS']) && $_SERVER['HTTP_HOST'] == 'mydomain.com') {
  // set this to "off" if your website does not use SSL
 $_SERVER['HTTPS'] = 'on';
}

if (!defined('FULL_BASE_URL')) {
 define('FULL_BASE_URL', 
'http'.(empty($_SERVER['HTTPS'])?'':'s').'://'.$_SERVER['HTTP_HOST']);
}



Hope that helps.

Adam

----- Original Message ----- 
From: "Walther" <[email protected]>
To: "CakePHP" <[email protected]>
Sent: Sunday, June 14, 2009 3:09 AM
Subject: Re: PHP Fatal error: Class 'Router' not found in 
cake\libs\view\helper.php on line 178



Well, if you use <a href =''>xxx</a> then it's not using the router is
it?

Why would you want to be outputting links in a shell script anyway?

On Jun 13, 10:57 am, joshua <[email protected]> wrote:
> Why if I change to $html->link to <a href =''>xxx</a>, there will be no 
> this
> error?
> Did that mean we couldn't use html helper in shell script?
>
>
>
> On Sat, Jun 13, 2009 at 2:01 PM, AD7six <[email protected]> wrote:
>
> > On Jun 13, 5:19 am, joshua <[email protected]> wrote:
> > > Hi Cakes,
> > > Is there anybody come across this problem? When I try to run cron job 
> > > in
> > > cake console, it print out this error.
>
> > > PHP Fatal error: Class 'Router' not found in cake\libs\view\helper.php
> > on
> > > line 178
>
> > > If I change to $html->link to <a href =''>xxx</a>, there will be no 
> > > this
> > > error.
>
> > > My Shell Scripts like this:
> > > [code]
> > > class AbcShell extends Shell {
> > > var $uses = array('modelA' );
> > > var $helpers = array('Html','Javascript');
>
> > > function main(){
> > > //....
> > > }
>
> > > [/code]
>
> > > Is there anything I missed? Thanks in advance for your reply.
>
> > The router isn't needed for shell access, so most likely that's the
> > reason it's not loaded.
>
> > AD
>
> --
> Thanks
> Joshua




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
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