Mirko Pagliai
Mirko Pagliai

Reputation: 1241

CakePHP 3.x: hide shell class

I have a src/Shell/AppShell.php class that is extended to all other shell classes and which contains common methods used by all other classes. In other words, this class doesn't contain any method callable directly.

If I launch the console:

bin/cake

the class is automatically detected and is shown:

$ bin/cake

Welcome to CakePHP v3.0.6 Console
[...]
Available Shells:
[...]
[MyPlugin] app, compress, install
[...]

$ bin/cake MeTools.app
Usage:
cake my_plugin.app [-h] [-v] [-q]

Options:

--help, -h     Display this help.
--verbose, -v  Enable verbose output.
--quiet, -q    Enable quiet output.

How to hide it and not make it executable? Thanks.

Upvotes: 0

Views: 106

Answers (1)

ndm
ndm

Reputation: 60463

The available shells are being retrieved by scanning the shell folders for .php files.

Exclusions are only made to the list of shells that live in the main app and the core (AppShell, CommandListShell and CompletionShell are being hidden by default), the plugin shell list is not going to be filtered, so the only way to hide such a shell would be to either

  • use a non .php file extension (not a very good idea as it breaks the default PSR-4 autoloader)
  • or move the base shell class to a different directory (a subdirectory in the shell folder should do it)

Upvotes: 1

Related Questions