Cakephp shell :Shell class HelloShell could not be found

前端 未结 3 1605
名媛妹妹
名媛妹妹 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: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

提交回复
热议问题