Harsha M V
Harsha M V

Reputation: 54949

Running CakePHP Shell Script

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}

Upvotes: 5

Views: 19341

Answers (4)

Yoseph
Yoseph

Reputation: 660

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.

Upvotes: 1

uzyn
uzyn

Reputation: 6683

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

cd C:\wamp\www\gitgrow\app
Console\cake email

Upvotes: 2

Krishna
Krishna

Reputation: 1540

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

Upvotes: 6

ifunk
ifunk

Reputation: 637

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

Upvotes: 1

Related Questions