Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

PHP Fatal error: Class 'AppShell' not found #82

Open
mwinters0 opened this issue Feb 11, 2015 · 8 comments
Open

PHP Fatal error: Class 'AppShell' not found #82

mwinters0 opened this issue Feb 11, 2015 · 8 comments

Comments

@mwinters0
Copy link

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:

<?php
App::uses('CakeEmail', 'Network/Email');

class EmailQueueWorkerShell extends AppShell {

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.

@wa0x6e
Copy link
Owner

wa0x6e commented Feb 11, 2015

Do you also have this error when trying to execute the job directly in the shell ?

@mwinters0
Copy link
Author

If I add

    public function main() {
        echo "Yarp\n";
    }

to the EmailQueueWorkerShell I can Console/cake emailQueueWorker and it will echo "Yarp" without complaint.

@mwinters0
Copy link
Author

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');
    }
}

@wa0x6e
Copy link
Owner

wa0x6e commented Feb 11, 2015

Do you have an 'exotic' installation ? Did you install CakePHP via composer too ? Did you install the plugin in another folder ?

@mwinters0
Copy link
Author

I don't think I have anything exotic, but this is a medium-sized app.

  • CakePHP is not installed via composer, and is not "shared" on my system.
  • My composer autoload.php is loaded at the top of bootstrap via App::import('Vendor', array('file' => 'autoload'));.
  • The plugin was installed via composer, and seems to be in the standard location (/app/Plugin/CakeResque).
  • The plugin was loaded at the end of bootstrap via CakePlugin::load(array('CakeResque' => array('bootstrap' => true))); with totally default settings.
  • I don't have any other Plugins installed, not even DebugKit
  • I don't have unusual environment variables set, and I'm using bash to call the CakeResque shell.
  • I've never had any "Missing Class" problems before.

Any suggestions of what I could check?

@domstubbs
Copy link

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.

@mwinters0
Copy link
Author

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 :)

@Harrrrry
Copy link

Harrrrry commented Jul 25, 2017

@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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants