Cakephp shell :Shell class HelloShell could not be found

前端 未结 3 1590
名媛妹妹
名媛妹妹 2020-12-20 14:17

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

相关标签:
3条回答
  • 2020-12-20 14:23

    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.

    0 讨论(0)
  • 2020-12-20 14:37

    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.

    0 讨论(0)
  • 2020-12-20 14:46

    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".

    enter image description here

    Reference: http://book.cakephp.org/2.0/en/console-and-shells.html#creating-a-shell

    0 讨论(0)
提交回复
热议问题