5

I have created a shell script as follows

<?php

class EmailShell extends AppShell
{
    public function main()
    {
        $this->out('Hello world.');
    }
}

When i navigate to the Console folder in command line and type cake email i get the following error.

Error: Shell class EmailShell could not be found.
#0 C:\wamp\www\gitgrow\lib\Cake\Console\ShellDispatcher.php(167): ShellDispatche
r->_getShell('email')
#1 C:\wamp\www\gitgrow\lib\Cake\Console\ShellDispatcher.php(69): ShellDispatcher
->dispatch()
#2 C:\wamp\www\gitgrow\app\Console\cake.php(33): ShellDispatcher::run(Array)
#3 {main}
Harsha M V
  • 54,075
  • 125
  • 354
  • 529
  • see more: http://stackoverflow.com/questions/10671634/cakephp-shell-shell-class-helloshell-could-not-be-found/26845978#26845978 – Vy Do Nov 10 '14 at 14:27

4 Answers4

6

create a shell for use in the Console. For this example, we’ll create a simple Hello world shell. In you applications Console/Command directory create EmailShell.php. Put the following code inside it:

class EmailShell extends AppShell {
    public function main() {
        $this->out('Hello world.');
    }
}

Then run this command :

Console/cake email

or

cake email
Krishna
  • 1,540
  • 2
  • 11
  • 25
2

Run it at C:\wamp\www\gitgrow\app\. It should work.

cd C:\wamp\www\gitgrow\app
Console\cake email
uzyn
  • 6,625
  • 5
  • 22
  • 41
  • This worked but this is a totally unintuitive choice on the part of the Cake devs. I'm on Windows. It works when you're in the `/app` folder and you run `Console\cake email`. But if you are **already** in the `Console` folder and you run `cake email` it doesn't work. That's just ridiculous! Especially since they have you add the `Console` folder to the system path. ?!? – Costa Nov 10 '12 at 00:31
1

If your shell class is in the right place, then it might be a problem that cake does not know where your app root is. You can specify this using the -app argument.

cake -app ../app email
ifunk
  • 627
  • 4
  • 10
1

See the following link about how to run Cake shells in cron:

http://book.cakephp.org/2.0/en/console-and-shells/cron-jobs.html

Your cron command basically calls cd into the app directory and the cake command to run the shell together.

Yoseph
  • 608
  • 9
  • 22