Running commands attempts to load shell instead



I’m attempting to create a simple Command using an example from the CakePHP documentation found here.

I bake a command using bin/cake bake command Hello, thus creating a file called HelloCommand.php inside src/Command/.

The file contains the exact code the above link contains. However on running the command from console with the following command:

bin/cake hello

I get the following error:

Exception: Shell class for "Hello" could not be found. in [X:\xampp\htdocs\tools\vendor\cakephp\cakephp\src\Console\ShellDispatcher.php, line 327]

Why is it attempting to open a shell instead of the command. Am I missing something? If so I find it pretty unclear in the documentation.

Using CakePHP Version 3.6.4


Did you add changes in PATH ?
“Adding cake to your system path”


You linked the 2.X documentation, but I’m on 3.X. On 3.X, I don’t believe you need to add the executable path to the PATH system variable. Instead you cd into your app folder, and run bin/cake.

Nevertheless, I added X:\xampp\htdocs\tools\bin to my System Variable called PATH, to no avail. Still the same error.

I can run shells fine without issues. I made a shell called ToolsShell. When I run bin/cake tools everything works fine. It’s only when I try to run a command, I have issues.


Please, clarify :
You have some thing like :

class ToolsShell extends AppShell {
function hello(){}

bin/cake tools hello - Doesn’t works ?


Hi, thanks.

Sorry for being unclear.

I have a file called HelloCommand.php inside src\Command folder.

Inside that file is the following code:

File structure:

On the terminal, I’ve traversed using cd into my project folder. I run the command bin/cake Hello.

According to the documentation that should output Hello World. But I get the error shown in the top post.


The reason I brought up the ToolsShell example, was to show that running Shells work perfectly according to documentation, but I understand Shell are deprecated.

I have this file inside src\Shell:

When I run bin/cake Tools prolongedCheckouts, I get printed out all the rows I get using $this->Model->find().

So in essence: Shells work, Commands do not.