Laravel中的exec()函数在修补程序和控制台中正常运行 [英] exec() function within Laravel works wrong, in tinker and console properly

查看:172
本文介绍了Laravel中的exec()函数在修补程序和控制台中正常运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Laravel应用程序中的exec函数有一个奇怪的问题.使用imagemagick库,我必须合并两个pdf文件-相同的shell命令在终端中可以正常工作,exec()与tinker中的此命令也可以正常工作.但是,当从Laravel应用程序中的作业或控制器调用时,看起来根本看不到原始文件.可能是什么原因?所有文件都存储在生成的存储子文件夹中.

I have a weird problem with exec function within the Laravel app. Using imagemagick library I have to combine two pdf files - the same shell command works properly in terminal, exec() with this command in tinker works properly too. However, when called from job or controller within the Laravel app it looks like it is not seeing the original file at all. What can be the reason? All files are stored in generated storage subfolders.

  • 在修补匠中正常工作
  • 在终端中正常工作
  • 在Laravel应用程序外的简单测试php文件中可以正常工作
  • 在Laravel应用程序内的作业/控制器中不起作用(看起来它没有在读取输入文件_1.pdf(输出文件仅由覆盖文件生成,没有源背景"))已经尝试过Process :: class,exec用来简化代码.权限设置正确.
exec('convert "/Users/robert/Sites/start-app/storage/documents/file_1.pdf" null: "/Users/robert/Sites/start-app/storage/documents/stamps/1.png" -gravity SouthEast -geometry +150+150 -compose over -layers composite "/Users/robert/Sites/start-app/storage/documents/processed/output_file_1.pdf"');

推荐答案

您是否有用于服务Web请求和处理cli的不同php.ini文件?这些通常存储在以下(或类似的)文件夹中

Do you have different php.ini files for servering web requests and handling cli? These are usually stored in the following (or similar) folders

/etc/php/7.3/cli/php.ini
/etc/php/7.3/fpm/php.ini

您还可以通过从cli和网络请求中运行 phpinfo()进行检查,并进行比较.

You can also check this by running phpinfo() from the cli and also from a web request and compare both.

在这种情况下,您应该签出 disable_functions 选项.可以在此处找到更多信息>.请记住,之后再重新启动Web服务器,以使更改生效.

If that's the case you should check out the disable_functions option. More info on that can be found here. Remember to restart your webserver afterwards, so the changes take effect.

这篇关于Laravel中的exec()函数在修补程序和控制台中正常运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆