exec only returns the exit status of what it's executing.
Try this way:
exec(Storage::disk('maj')->get("maj.bat"), $output);
// $output is an array of lines now
dd($output);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello, I've got a problem with my php code in Laravel:
$output=exec(Storage::disk('maj')->get("maj.bat"));
return $output;
my" maj.bat" file:
cd c:\xampp\htdocs\gescrem2
git status -uno
And I get nothing in my $output ????? (no error)
Although I get in my terminal:
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: app/Http/Controllers/HomeController.php
no changes added to commit (use "git add" and/or "git commit -a")
Is somebody can help me, Thanks.
I got it :-) not perfect, but it works.
system("cmd /c C:\xampp\htdocs\gescrem2\storage\maj\maj.bat");
Please or to participate in this conversation.