Open mwinters0 opened 9 years ago
Do you also have this error when trying to execute the job directly in the shell ?
If I add
public function main() {
echo "Yarp\n";
}
to the EmailQueueWorkerShell I can Console/cake emailQueueWorker
and it will echo "Yarp" without complaint.
Here is my full EmailQueueWorkerShell.php:
<?php
App::uses('CakeEmail', 'Network/Email');
class EmailQueueWorkerShell extends AppShell {
public function main() {
echo "Yarp\n";
}
public function sendEmail() {
CakeLog::debug('EmailWorker got args: ' . print_r($this->args, true), 'email');
}
}
Do you have an 'exotic' installation ? Did you install CakePHP via composer too ? Did you install the plugin in another folder ?
I don't think I have anything exotic, but this is a medium-sized app.
App::import('Vendor', array('file' => 'autoload'));
.CakePlugin::load(array('CakeResque' => array('bootstrap' => true)));
with totally default settings.Any suggestions of what I could check?
I have been setting up CakeResque today and noticed the same problem. In my case I just needed to explicitly load AppShell:
<?php
App::uses('CakeEmail', 'Network/Email');
App::uses('AppShell', 'Console/Command');
class ReportShell extends AppShell {
The example shell in the 'creating job classes' docs does reference this, but it's easy to miss.
Thanks for a great plugin.
Ah yes, that corrected the issue for me. The manual AppShell reference is mentioned at http://cakeresque.kamisama.me/usage#jobs but not http://cakeresque.kamisama.me/usecases#sending-emails . Thanks domstubbs and kamisama. Leaving this open so kamisama can reference it when updating the docs :)
@wa0x6e Do you also have this error when trying to execute the job directly in the shell? yes, I am getting the error when executing the command direct in the shell
Class 'App' not found in
CakePHP 2.6.1, PHP 5.5.9, Ubuntu 14, cake-resque installed via composer:
"kamisama/cake-resque": "4.1.*"
I'm following the tutorial at http://cakeresque.kamisama.me/usecases#sending-emails almost exactly, but receiving the following (abbreviated) error in resque-worker-error.log:
PHP Fatal error: Class 'AppShell' not found in [...]/app/Console/Command/EmailQueueWorkerShell.php on line 4
Here are the first 4 lines of EmailQueueWorkerShell.php:
The worker was started with
Console/cake CakeResque.CakeResque start --queue email
Here's the queue code, from within an event listener:
CakeResque::enqueue('email', 'EmailQueueWorkerShell', array('sendEmail', $config));
where $config is an Array.I do have an AppShell in my project's Command directory, with the
perform()
method added per the tutorial. AppShell is otherwise empty. I also have other shells extending AppShell which I can run without issue.