34 lines
890 B
PHP
34 lines
890 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Process\Pipe;
|
|
use Illuminate\Support\Facades\Process;
|
|
|
|
class GitPullController extends Controller
|
|
{
|
|
public function index(Request $request)
|
|
{
|
|
$request->validate([
|
|
'command' => ['sometimes', 'string']
|
|
]);
|
|
|
|
$result = Process::pipe(function (Pipe $pipe) {
|
|
$pipe->command('ls -la');
|
|
// $pipe->command('grep -i "laravel"');
|
|
}, function (string $type, string $output) {
|
|
echo $output;
|
|
});
|
|
|
|
return [
|
|
'successful' => $result->successful(),
|
|
'failed' => $result->failed(),
|
|
'exitCode' => $result->exitCode(),
|
|
'output' => $result->output(),
|
|
'errorOutput' => $result->errorOutput(),
|
|
];
|
|
// return '<pre>'.$result->output().'</pre>';
|
|
}
|
|
}
|