简体   繁体   English

CakePHP 3:执行控制台命令会显示“未知命令” cake hello”错误

[英]CakePHP 3: Executing console command gives 'Unknown Command `cake hello`' error

I have been developing locally on a simple cake project creating a console command following the Console Commands documentation. 我一直在本地开发一个简单的Cake项目,并根据Console Commands文档创建了Console命令 When moving all of the work to the development server running a separate copy of CakePHP (server running version CakePHP 3.5.13 local version running CakePHP 3.6), trying to run the bin/cake hello command gives the following error: 将所有工作移到运行单独的CakePHP副本的开发服务器上(服务器运行的版本CakePHP 3.5.13本地版本运行CakePHP 3.6)时,尝试运行bin/cake hello命令会出现以下错误:

Exception: Unknown command 'cake hello'. Run 'cake --help' to get the list of valid commands. in [/var/www/vhosts/[SERVER_NAME]/vendor/cakephp/cakephp/src/Console/CommandRunner.php, line 177]

I have tried creating a new console command from scratch directly on the server but end up with same error which should rule out the command code being the issue. 我尝试直接在服务器上从头开始创建新的控制台命令,但最终遇到相同的错误,这应该排除命令代码是问题所在。

All files are in the correct place: src/Command/HelloCommand.php 所有文件都位于正确的位置: src/Command/HelloCommand.php

The HelloCommand.php code is exactly the same as the example in the documentation. HelloCommand.php代码与文档中的示例完全相同。

I am at a miss as to why it cannot find the command. 对于它为什么找不到命令,我感到很想念。 It also doesn't appear in the list of commands when running cake --help . 运行cake --help时,它也不会出现在命令列表中。

Is there something I have missed to give CakePHP sight to the newly created console commands? 我想念一下CakePHP新创建的控制台命令吗? Is there any reason why the command runs fine locally but differently on a remote server or have I just missed something! 是否有任何原因导致命令在本地运行良好,但在远程服务器上运行的方式有所不同,或者我只是错过了某些内容!

Thanks 谢谢

Commands are only available as of CakePHP 3.6, in earlier versions you have to use Shells. 命令仅从CakePHP 3.6起可用,在早期版本中,您必须使用Shell。

Side note: do not use different CakePHP versions, your development and prodution environments should be as identical as possible if you don't want to get in trouble! 注意:不要使用不同的CakePHP版本,如果您不想惹上麻烦,您的开发和生产环境应尽可能相同!

See also 也可以看看

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM