从laravel控制器调用shell命令吗? [英] Call shell commands from laravel controller?

查看:327
本文介绍了从laravel控制器调用shell命令吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从laravel控制器调用Shell命令(例如,用于转换图像)?如果是,那么如何.我已经在互联网上搜索了.似乎没有任何关系.请指导.

Is it possible to call Shell commands (e.g for converting images ) from laravel controller? If yes then how. I have searched on internet. Nothing seems relevant. Please Guide.

谢谢

推荐答案

您可以使用Symfony提供的Process组件: http://symfony.com/doc/current/components/process.html

You can use the Process component provided by Symfony: http://symfony.com/doc/current/components/process.html

该组件由Laravel本身使用,因此可以直接加载.

The component is used by Laravel itself, so it can be loaded directly.

如果使用它(而不是php的exec()函数),则可以对调用shell命令的代码进行单元测试.

If you use it(instead of php's exec() function), you'll be able to unit test the code that calls shell commands.

这篇关于从laravel控制器调用shell命令吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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