Not sure if cake has a prettier, more efficient way of grabbing components inside of Shells and Tasks with cakephp’s cli, but here is a way which worked for me. Inside your Task (or Shell) just use the following in a similar manner for your component:


class FooTask extends Shell {
	App::import('Component', 'Bar');

	$this->Bar =& new BarComponent();

	$resp = $this->Bar->crazy_things();
	$this->out($resp);
}

Of course Foo and Bar are just for example. This works for me. Anyone know of another way?

Be Sociable, Share!

Related posts:

  1. Adding PostgreSQL Regex Support in CakePHP
  2. Using Subqueries as Fields in CakePHP
  3. CakePHP, PostgreSQL, and Regex
  4. Handling TimeZones in CakePHP
  5. Scheduled Tasks Super Easy in Ubuntu