Call shell commands from Laravel controller?

后端 未结 2 743
别那么骄傲
别那么骄傲 2021-02-14 12:15

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.

相关标签:
2条回答
  • 2021-02-14 13:03

    It all depends on what operating system you are using. php already has a few functions to execute shell commands.

    Laravel has a build in task runner for ssh commands.

    0 讨论(0)
  • 2021-02-14 13:12

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

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

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

    0 讨论(0)
提交回复
热议问题