我正在尝试为我的应用程序使用cakephp shell来执行任务。该任务涉及运行长时间运行的进程(因此需要使用shell)。使用CakePHP + Shell中的组件
功能要求我使用了一个名为CommonComponent
组件内部的功能不幸的是,每当我尝试包括我得到以下错误 PHP的致命错误的组件:类“组件”在/ var/WWW未找到/nginx-test/app/Controller/Component/CommonComponent.php
这里是CronShell类,这是被称为
class CronShell extends AppShell {
public function main() {
$this->out('Hello world.');
// $this->out(phpinfo());
}
public function test()
{
$this->out('Before Import');
App::import('Component', 'Common');
$this->out('Import complete');
// $this->Common=ClassRegistry::init('CommonComponent');
$this->Common =new CommonComponent();
$this->out('Initialization complete');
$this->Common->testCron();
$this->out('FunctionCall complete');
//$this->Common->saveCacheEntry("name","value");
}
}
的CommonComponent类被存储为应用程序/控制器/元件及ent/CommonComponent.php,如下所示
class CommonComponent extends Component
{
function testCron()
{
$this->out('Hello world from Component.');
}
}
任何想法?
考虑更新接受的答案吗? – 2013-04-23 20:28:04