I am a newer to cakephp .I config the cakephp shell as the cakephp handbook says,when I run the HelloShell with the command cake Hello ,I got the error information as follo
Make sure you give cake folder path in /var/www/html/Console/cake.php ini_set('include_path', $root . PATH_SEPARATOR . 'Cake' . $ds . 'lib' . PATH_SEPARATOR . ini_get('include_path'));
Then go to root folder. In my case the location will be /var/www/html/ then give the shell file name; hello is my shell name, that would be /var/www/html/Console/cake hello combining together /var/www/html$ /var/www/html/Console/cake hello
Your shell will be executed.
there is your mistake. you should always be in your APP path to execute the cake console.
...app/>../lib/Cake/Console/cake MyShell
or (using the APP Console folder):
...app/>Console/cake MyShell
and MyShell should then be in ...app/Console/Command/
.
Thats all there is to it.
Error: Shell class HelloShell could not be found
appear because: typo mistake or run command at wrong directory.
Solution:
1. Setup path for php.exe, cake.exe
2. For example, my Cake website root is:
C:\tools\xampp1.8.3\htdocs\cakephp-2.5.5
Create new file in folder C:\tools\xampp1.8.3\htdocs\cakephp-2.5.5\app\Console\Command\HelloShell.php
with content:
class HelloShell extends AppShell {
public function main() {
$this->out('Hello world.');
}
}
3. Open cmd, type:
cd /d C:\tools\xampp1.8.3\htdocs\cakephp-2.5.5\app
cake hello
We use hello
in command line to call HelloShell
class, because "Convention over configuration".
Reference: http://book.cakephp.org/2.0/en/console-and-shells.html#creating-a-shell