私のアプリケーションにcakephpシェルを使ってタスクを実装しようとしています。この作業には、長時間実行されるプロセスの実行が含まれます(したがって、シェルを使用する必要があります)。Cakephp 2+ Shellのコンポーネントを使用する
機能は、コンポーネント内の機能を使用するために私を必要と私はコンポーネントを含めるようにしようとするたびに残念ながら、私は次のエラー PHPの致命的なエラーが出る
CommonComponent
呼ば:クラス「コンポーネント」の/ var/WWWには見られませんここ/nginx-test/app/Controller/Component/CommonComponent.phpはCommonComponentクラスはアプリ/コントローラ/ COMPONとして格納さ
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");
}
}
呼び出されるCronShellクラスでありますent/CommonComponent.phpであり、次のとおりです
class CommonComponent extends Component
{
function testCron()
{
$this->out('Hello world from Component.');
}
}
アイデアをお持ちですか?あなたのアプリLibの内からコードでなければなりませんシェルにインポート何
受け入れられた回答を更新することを検討してください。 –