cakephp: When executing a subcommand, can't the plugin name be camelCase?

Description

I can execute subcommands like cake my_plugin.my_command mysubcommand, but I cannot execute them with the plugin name in camel case, like cake MyPlugin.my_command mysubcommand. Is this a bug? The version of CakePHP is 5.0.9.

CakePHP Version

5.0.9

PHP Version

8.1

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (15 by maintainers)

Commits related to this issue

Most upvoted comments

However, when displaying the list of commands using cake --help, CamelCase seems more familiar and intuitive to me.

Totally agree that is inconsistent. We should give output that is easier to copy/paste.

The opposite should be the case: By default CLI commands are always underscored, so having the camelCase support seems weird and inconsistent. It could still work but probably should not be displayed. So:

bin/cake my_plugin_command bin/cake my_awesome_plugin.my_plugin_command

would both work with the first being shown - I would imagine.

The pattern in the URL is defined by the RouteClass which by default is the dashed route, so your case would be

http://xxxx.com/my-plugin/my-controller/my-action

But nonetheless, URL patterns shouldn’t dictate how we reference parts of our code - especially since this issue is CLI specific and therefore has nothing to do with how cake structures its URLs by default.

The only reason I can see plugin prefixes being useful is the fact, if 2 plugins provide the same command. Otherwise, bin/cake my_test wouldn’t be unique if both PluginA and PluginB provide the MyTestCommand class.

Therefore, I’d suggest we remove the plugin underscore behaviour in 6.x. Of course just calling bin/cake my_test will still work if that command is unique, but otherwise this can also - only - be called via bin/cake MyPlugin.my_test and not bin/cake my_plugin.my_test anymore