简体   繁体   English

Laravel 在 controller 中运行 package 工匠命令

[英]Laravel run package artisan command in controller

I need to run this command when user change something in translation file当用户更改翻译文件中的某些内容时,我需要运行此命令

php artisan export:messages-flat php 工匠出口:messages-flat

I need to add it in may controller我需要在 5 月添加它 controller

so I'm using this code所以我正在使用这段代码

\Artisan::call('export:messages-flat'); \Artisan::call('export:messages-flat');

but it return error saying that但它返回错误说

The command "export:messages-flat" does not exist.命令“export:messages-flat”不存在。

but when I但是当我

php artisan list php 工匠名单

在此处输入图像描述

it's in the list它在列表中

I also try to run other command我也尝试运行其他命令

\Artisan::call('cache:clear'); \Artisan::call('cache:clear');

and it works它有效

this is the package I'm using link这是我正在使用的 package 链接

kindly help me, sorry for may poor english请帮助我,抱歉英语可能很差

The package only allows you to run the commands from the CLI. package 仅允许您从 CLI 运行命令。 You can see from the source code , they only register the Artisan commands if the application is running from the console.您可以从源代码中看到,如果应用程序从控制台运行,它们只会注册 Artisan 命令。

As an alternative, you can call ExportLocalization::export()->toFlat() according to their documentation .作为替代方案,您可以根据他们的文档调用ExportLocalization::export()->toFlat()

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

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