0

I use public $uses = array('PluginA.ModelClass1'); to load the plugin model class in shell. And when I run the shell in command line, I got the following error:

Mac:Console charles$ ./cake PluginA.do_something test CAMPAIGN -c 1
Notice Error: Undefined property: DoSomethingShell::$ModelClass1 in [/Users/charles/Workspace/PHP/ProjectA/lib/Cake/Console/Shell.php, line 443]

PHP Fatal error:  Call to a member function exists() on a non-object in /Users/charles/Workspace/PHP/ProjectA/app/Plugin/PluginA/Console/Command/DoSomethingShell.php on line 91
PHP Stack trace:
PHP   1. {main}() /Users/charles/Workspace/PHP/ProjectA/app/Console/cake.php:0
PHP   2. ShellDispatcher::run() /Users/charles/Workspace/PHP/ProjectA/app/Console/cake.php:37
PHP   3. ShellDispatcher->dispatch() /Users/charles/Workspace/PHP/ProjectA/lib/Cake/Console/ShellDispatcher.php:68
PHP   4. Shell->runCommand() /Users/charles/Workspace/PHP/ProjectA/lib/Cake/Console/ShellDispatcher.php:200
PHP   5. DoSomethingShell->test() /Users/charles/Workspace/PHP/ProjectA/lib/Cake/Console/Shell.php:389

Fatal error: Call to a member function exists() on a non-object in /Users/charles/Workspace/PHP/ProjectA/app/Plugin/PluginA/Console/Command/DoSomethingShell.php on line 91

Call Stack:
    0.0003     228248   1. {main}() /Users/charles/Workspace/PHP/ProjectA/app/Console/cake.php:0
    0.0010     314344   2. ShellDispatcher::run() /Users/charles/Workspace/PHP/ProjectA/app/Console/cake.php:37
    0.0153    2075240   3. ShellDispatcher->dispatch() /Users/charles/Workspace/PHP/ProjectA/lib/Cake/Console/ShellDispatcher.php:68
    0.0201    2416216   4. Shell->runCommand() /Users/charles/Workspace/PHP/ProjectA/lib/Cake/Console/ShellDispatcher.php:200
    0.0262    3250056   5. DoSomethingShell->test() /Users/charles/Workspace/PHP/ProjectA/lib/Cake/Console/Shell.php:389

Fatal Error Error: Call to a member function exists() on a non-object in [/Users/charles/Workspace/PHP/ProjectA/app/Plugin/PluginA/Console/Command/DoSomethingShell.php, line 91]

The shell and loaded model class are all in the plugin PluginA. And in ModelClass1, there is a method called exists().

Thanks in advance!

Charles
  • 675
  • 3
  • 12
  • 21
  • possible duplicate of [Reference - What does this error mean in PHP?](http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) – kittycat Feb 02 '14 at 07:52
  • I tried the same setup and it seems to work. Can you paste more code from the shell? – cornelb Feb 02 '14 at 08:54
  • Are you in /app or /app/Console? Try cd'ing back to /app and executing ./Console/cake PluginA.do_something test CAMPAIGN -c 1 – Ben Hitchcock Feb 02 '14 at 13:04
  • Thank you very much for your help! And the issue is gone after I update my PHP. Maybe I didn't set up the PHP and cakePHP correctly. – Charles Feb 17 '14 at 09:08

0 Answers0