<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Writing a custom CakePHP console script</title>
	<atom:link href="http://cakebaker.42dh.com/2007/05/07/writing-a-custom-cakephp-console-script/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com/2007/05/07/writing-a-custom-cakephp-console-script/</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Tue, 16 Mar 2010 00:59:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Gonzalo</title>
		<link>http://cakebaker.42dh.com/2007/05/07/writing-a-custom-cakephp-console-script/comment-page-1/#comment-152708</link>
		<dc:creator>Gonzalo</dc:creator>
		<pubDate>Mon, 15 Mar 2010 20:27:55 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/05/07/writing-a-custom-cakephp-console-script/#comment-152708</guid>
		<description>I tried too to do:

&lt;code&gt;$player = $this-&gt;requestAction(&#039;/players/getProfile/6&#039;);&lt;/code&gt;

But I only get:
Error: Missing Controller &#039;Players&#039;

and my controller´s code is printed in the console</description>
		<content:encoded><![CDATA[<p>I tried too to do:</p>
<p><code>$player = $this-&gt;requestAction('/players/getProfile/6');</code></p>
<p>But I only get:<br />
Error: Missing Controller &#8216;Players&#8217;</p>
<p>and my controller´s code is printed in the console</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gonzalo</title>
		<link>http://cakebaker.42dh.com/2007/05/07/writing-a-custom-cakephp-console-script/comment-page-1/#comment-152707</link>
		<dc:creator>Gonzalo</dc:creator>
		<pubDate>Mon, 15 Mar 2010 20:23:29 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/05/07/writing-a-custom-cakephp-console-script/#comment-152707</guid>
		<description>I can´t load any cotnroller, I just get this message:

 &quot;Fatal error: Class &#039;Controller&#039; not found in C:\wamp\www\integracion\app\app_controller.php on line 2&#039;&quot;

the line 2 of my app_controller only have: 
&lt;code&gt;class AppController extends Controller {&lt;/code&gt;

my code is:
&lt;code&gt;class GiftShell extends Shell {
    var $uses = array(&#039;Player&#039;);
	var $tasks = array(&#039;Project&#039;,
				&#039;DbConfig&#039;,
				&#039;Controller&#039;,
				);

	var $PlayersController = null;

    function initialize()
	{
		$this-&gt;_loadModels();
	}

    function main() {
        App::import(&#039;Controller&#039;, &#039;Players&#039;);
	$this-&gt;PlayersController = new PlayersController();
        $this-&gt;PlayersController-&gt;constructClasses();
     
	}
}
?&gt;&lt;/code&gt;

Please if somebody can help me :S</description>
		<content:encoded><![CDATA[<p>I can´t load any cotnroller, I just get this message:</p>
<p> &#8220;Fatal error: Class &#8216;Controller&#8217; not found in C:\wamp\www\integracion\app\app_controller.php on line 2&#8242;&#8221;</p>
<p>the line 2 of my app_controller only have:<br />
<code>class AppController extends Controller {</code></p>
<p>my code is:<br />
<pre><code>class GiftShell extends Shell {
    var $uses = array('Player');
	var $tasks = array('Project',
				'DbConfig',
				'Controller',
				);

	var $PlayersController = null;

    function initialize()
	{
		$this-&gt;_loadModels();
	}

    function main() {
        App::import('Controller', 'Players');
	$this-&gt;PlayersController = new PlayersController();
        $this-&gt;PlayersController-&gt;constructClasses();
     
	}
}
?&gt;</code></pre>
<p>Please if somebody can help me :S</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2007/05/07/writing-a-custom-cakephp-console-script/comment-page-1/#comment-129681</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Wed, 03 Jun 2009 15:52:19 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/05/07/writing-a-custom-cakephp-console-script/#comment-129681</guid>
		<description>@Ulises: Hm, no idea why it doesn&#039;t work on your system... Do you get any output if you use $this-&gt;output(&#039;some text&#039;);?</description>
		<content:encoded><![CDATA[<p>@Ulises: Hm, no idea why it doesn&#8217;t work on your system&#8230; Do you get any output if you use $this-&gt;output(&#8217;some text&#8217;);?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ulises Figueroa</title>
		<link>http://cakebaker.42dh.com/2007/05/07/writing-a-custom-cakephp-console-script/comment-page-1/#comment-129621</link>
		<dc:creator>Ulises Figueroa</dc:creator>
		<pubDate>Tue, 02 Jun 2009 16:59:47 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/05/07/writing-a-custom-cakephp-console-script/#comment-129621</guid>
		<description>@cakebaker: I mean that even though I have set the Debug Mode to 1 or 2 I doesnt shows up any message from pr() or echo. I&#039;m not getting any error from Linux bash nor the CakePHP shell. :S</description>
		<content:encoded><![CDATA[<p>@cakebaker: I mean that even though I have set the Debug Mode to 1 or 2 I doesnt shows up any message from pr() or echo. I&#8217;m not getting any error from Linux bash nor the CakePHP shell. :S</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2007/05/07/writing-a-custom-cakephp-console-script/comment-page-1/#comment-129512</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Mon, 01 Jun 2009 08:42:11 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/05/07/writing-a-custom-cakephp-console-script/#comment-129512</guid>
		<description>@Ulises: Good to hear you could figure out your first issue in the meantime :)  

What do you mean with &quot;it doesn&#039;t show up any message&quot;? Do you mean the output of the &quot;pr&quot; function is not shown? Is it possible that the debug level is set to 0? In that case the &quot;pr&quot; function doesn&#039;t output anything by design (see cake/basics.php). Try to add the following snippet to your script:
&lt;pre&gt;
&lt;code&gt;
Configure::write(&#039;debug&#039;, 1);
&lt;/code&gt;
&lt;/pre&gt;
Hope that helps!</description>
		<content:encoded><![CDATA[<p>@Ulises: Good to hear you could figure out your first issue in the meantime :)  </p>
<p>What do you mean with &#8220;it doesn&#8217;t show up any message&#8221;? Do you mean the output of the &#8220;pr&#8221; function is not shown? Is it possible that the debug level is set to 0? In that case the &#8220;pr&#8221; function doesn&#8217;t output anything by design (see cake/basics.php). Try to add the following snippet to your script:</p>
<pre>
<code>Configure::write('debug', 1);</code>
</pre>
<p>Hope that helps!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ulises Figueroa</title>
		<link>http://cakebaker.42dh.com/2007/05/07/writing-a-custom-cakephp-console-script/comment-page-1/#comment-129310</link>
		<dc:creator>Ulises Figueroa</dc:creator>
		<pubDate>Fri, 29 May 2009 22:39:46 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/05/07/writing-a-custom-cakephp-console-script/#comment-129310</guid>
		<description>It works now, I changed the app directory when calling the script from shell. 

/home/user/public_html/website/cake/console/cake member -app  /home/user/public_html/website/app

But now it doesnt show up any message, how do I debugg the script from shell ??  Any ideas?</description>
		<content:encoded><![CDATA[<p>It works now, I changed the app directory when calling the script from shell. </p>
<p>/home/user/public_html/website/cake/console/cake member -app  /home/user/public_html/website/app</p>
<p>But now it doesnt show up any message, how do I debugg the script from shell ??  Any ideas?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ulises Figueroa</title>
		<link>http://cakebaker.42dh.com/2007/05/07/writing-a-custom-cakephp-console-script/comment-page-1/#comment-129309</link>
		<dc:creator>Ulises Figueroa</dc:creator>
		<pubDate>Fri, 29 May 2009 22:09:11 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/05/07/writing-a-custom-cakephp-console-script/#comment-129309</guid>
		<description>I set up a Shell and a Task, Im using a Model to reach some data and send an email. But when I execute the shell I got the following error: 

Error: Missing Database Connection. Try &#039;cake bake&#039;

This is the code for the Shell and Task

class MemberShell extends Shell {
   var $tasks = array(&#039;NotifyNewMessage&#039;);
   
   function main() {

   		pr(&#039;Aqui va&#039;);   	
       $this-&gt;NotifyNewMessage-&gt;execute();
   }
}

class NotifyNewMessageTask extends Shell {
   var $uses = array(&#039;Message&#039;, &#039;Member&#039;);
   var $components = array (&#039;MemberMailer&#039;);
   
   function execute() { 
     //Reach data and send Email
  }
}</description>
		<content:encoded><![CDATA[<p>I set up a Shell and a Task, Im using a Model to reach some data and send an email. But when I execute the shell I got the following error: </p>
<p>Error: Missing Database Connection. Try &#8216;cake bake&#8217;</p>
<p>This is the code for the Shell and Task</p>
<p>class MemberShell extends Shell {<br />
   var $tasks = array(&#8216;NotifyNewMessage&#8217;);</p>
<p>   function main() {</p>
<p>   		pr(&#8216;Aqui va&#8217;);<br />
       $this-&gt;NotifyNewMessage-&gt;execute();<br />
   }<br />
}</p>
<p>class NotifyNewMessageTask extends Shell {<br />
   var $uses = array(&#8216;Message&#8217;, &#8216;Member&#8217;);<br />
   var $components = array (&#8216;MemberMailer&#8217;);</p>
<p>   function execute() {<br />
     //Reach data and send Email<br />
  }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2007/05/07/writing-a-custom-cakephp-console-script/comment-page-1/#comment-113525</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Wed, 26 Nov 2008 16:17:33 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/05/07/writing-a-custom-cakephp-console-script/#comment-113525</guid>
		<description>@calzone: I&#039;m glad I could help!</description>
		<content:encoded><![CDATA[<p>@calzone: I&#8217;m glad I could help!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: calzone</title>
		<link>http://cakebaker.42dh.com/2007/05/07/writing-a-custom-cakephp-console-script/comment-page-1/#comment-113194</link>
		<dc:creator>calzone</dc:creator>
		<pubDate>Fri, 21 Nov 2008 16:56:46 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/05/07/writing-a-custom-cakephp-console-script/#comment-113194</guid>
		<description>Brilliant cakebaker! 

I&#039;ve been chasing my tail over this one for a couple days now and I just knew it had to be some key element I was missing somewhere.

Thank you so much, your help has been invaluable.

--btw, happy holidays!</description>
		<content:encoded><![CDATA[<p>Brilliant cakebaker! </p>
<p>I&#8217;ve been chasing my tail over this one for a couple days now and I just knew it had to be some key element I was missing somewhere.</p>
<p>Thank you so much, your help has been invaluable.</p>
<p>&#8211;btw, happy holidays!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2007/05/07/writing-a-custom-cakephp-console-script/comment-page-1/#comment-113190</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Fri, 21 Nov 2008 15:39:05 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/05/07/writing-a-custom-cakephp-console-script/#comment-113190</guid>
		<description>@calzone: Thanks for your comment!

To avoid the &quot;Call to a member function on a non-object .” error you have to initialize the controller after it is instantiated: 
&lt;code&gt;
$this-&gt;CitiesController = new CitiesController();
$this-&gt;CitiesController-&gt;constructClasses();
...
&lt;/code&gt;
Hope that helps!</description>
		<content:encoded><![CDATA[<p>@calzone: Thanks for your comment!</p>
<p>To avoid the &#8220;Call to a member function on a non-object .” error you have to initialize the controller after it is instantiated:<br />
<pre><code>$this-&gt;CitiesController = new CitiesController();
$this-&gt;CitiesController-&gt;constructClasses();
...</code></pre><br />
Hope that helps!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
