I am trying to implement a task using cakephp shell for my application. The task is to start a long process (hence the need to use a shell).
The function requires me to use the function inside the CommonComponent Component
Unfortunately, when I try to enable a component, I get the following PHP error Fatal error: Class 'Component' not found in / var / www / nginx -test / app / Controller / Component / CommonComponent.php
Here is the CronShell class called
class CronShell extends AppShell {
public function main() {
$this->out('Hello world.');
}
public function test()
{
$this->out('Before Import');
App::import('Component', 'Common');
$this->out('Import complete');
$this->Common =new CommonComponent();
$this->out('Initialization complete');
$this->Common->testCron();
$this->out('FunctionCall complete');
}
}
The CommonComponent class is stored as app / Controller / Component / CommonComponent.php and looks like this
class CommonComponent extends Component
{
function testCron()
{
$this->out('Hello world from Component.');
}
}
Any ideas?
source
share