PHP Artisan Optimize在生产服务器上失败 [英] Php artisan optimize is failing on production server
问题描述
通过bash脚本在生产服务器上运行composer install
在post-install-cmd
php artisan optimize
处失败,错误为There are no commands defined in the "jwt" namespace
.
Running composer install
on a production server via a bash script is failing at post-install-cmd
php artisan optimize
with the error There are no commands defined in the "jwt" namespace
.
要尝试解决此问题,我在php artisan optimize
To try to resolve the issue I added the following commands before php artisan optimize
"php artisan clear-compiled",
"php artisan cache:clear",
"php artisan config:clear",
"php artisan config:cache",
"php artisan clear-compiled",
"php artisan cache:clear",
"php artisan config:clear",
"php artisan config:cache",
在本地运行composer install
可以正常工作.我可以毫无问题地通过脚本在本地运行命令.
Running composer install
locally works fine. I can run the commands through a script locally without a problem.
通过生产服务器上的脚本运行composer install
时发生故障.如果我登录到服务器并手动运行命令,则不会产生错误.
The failure is happening while running composer install
through a script on the production server. If I log onto the server and run the commands manually I do not generate the error.
不确定如何调试,有什么想法吗?
Not sure how to debug, any ideas?
推荐答案
尝试在服务器上的composer.json
文件内添加预安装事件,请注意,只有当您的composer.lock
存在并且您跑composer install
:
Try adding a pre-install event inside of your composer.json
file on the server, note that this event works only if your composer.lock
is present and you ran composer install
:
"scripts": {
"pre-install-cmd": [
"php artisan config:clear"
],
...
}
这篇关于PHP Artisan Optimize在生产服务器上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!