Brotzka's avatar

Running cmd commands / shell-scripts from Controller

Hey,

is it possible to run shell-scripts or shell-commands from within a Laravel controller? Artisan commands are not the problem because of the Artisan::call() command.

What I want, is to execute scripts or commands. Especially composer or git commands. These commands should be executed from the projects root directory. So I get errors running these commands from within a controller via shell_exec() or exec().

Any ideas how to solve this problem? Is there a php function to run a complete script, not only one command? Of course, I could write a php script and get every command done.

Thanks!

0 likes
3 replies
Brotzka's avatar

@goatshark Does this execute the commands in the projects root directory? As you know, it makes no sense to run composer commands from another location than the root directory..^^

And is it possible to run git commands?

Please or to participate in this conversation.