php - 无法从路由运行 Laravel Artisan 命令
问题描述
我有一个可执行的 shell 文件,并且可以从 CLI 命令成功运行它,但是我在从路由运行这个工匠命令时遇到了一些问题。
当我从终端运行它时,我得到了预期的输出消息并且文件被复制,但是从路由运行它既不会在日志中显示任何内容,也不会复制文件“cp .env .env.test”。
我正在使用 laravel 5.6 并在 Mac 上的本地环境中尝试这个。
这是外壳文件(shell.sh):
#!/bin/sh
php artisan cache:clear
cp .env .env.test
这是工匠指挥部
protected $signature = 'shell:run';
protected $description = 'Run sheel file';
public function __construct()
{
parent::__construct();
}
public function handle()
{
$output = shell_exec('./shell.sh');
$this->info($output);
}
和路线:
Route::get('/shell', function () {
Artisan::call('shell:run');
});
解决方案
推荐阅读
- time-series - 如何创建这种类型的循环?
- azure - Azure DevOps Services 是否支持租户限制?
- c - 在初始化指针数组时,为什么只有字符串不显示警告?
- java - maven-war 插件战争生成时间
- graphql-java - graphql-java:如何在以编程方式生成 graphql 模式时添加自定义标量类型?
- google-sheets - 查找当前月份在 Google 表格中的日期范围之间的天数
- internet-explorer - IE 11 win 10 文本框已禁用
- php - 需要为子目录中的多个 WordPress 或 WordPress 多站点虚拟子目录到根目录的 IIS 重写规则
- google-apps-script - 如何在 Google 幻灯片 apt 脚本 replaceAllText 中执行请求
- javascript - 如何放置一个可以在没有焦点按钮的情况下使用的 keyPress 处理程序?