mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-18 15:50:50 +08:00
plugin management + user tables and torrents table text column migrate
This commit is contained in:
52
app/Http/Controllers/PluginController.php
Normal file
52
app/Http/Controllers/PluginController.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Repositories\PluginRepository;
|
||||
use App\Repositories\ToolRepository;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Symfony\Component\Process\Process;
|
||||
use Telegram\Bot\Api;
|
||||
use Telegram\Bot\Commands\HelpCommand;
|
||||
|
||||
class PluginController extends Controller
|
||||
{
|
||||
private $repository;
|
||||
|
||||
public function __construct(PluginRepository $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
|
||||
public function runCommandSSE(Request $request)
|
||||
{
|
||||
$commands = [
|
||||
['pwd'], // Example command 1
|
||||
['ls', '-la'], // Example command 2
|
||||
['composer', '--version'], // Example command 3
|
||||
['composer', 'why', 'ext-zip']
|
||||
];
|
||||
foreach ($commands as $command) {
|
||||
$process = new Process($command);
|
||||
$process->setTimeout(0); // Set timeout for each process
|
||||
|
||||
try {
|
||||
$process->mustRun(function ($type, $buffer) {
|
||||
if (Process::OUT === $type) {
|
||||
echo "Output: " . $buffer; // 实时输出
|
||||
} else { // Process::ERR === $type
|
||||
echo "Error: " . $buffer;
|
||||
}
|
||||
});
|
||||
} catch (\Symfony\Component\Process\Exception\ProcessFailedException $e) {
|
||||
echo "Command failed: " . implode(' ', $command) . "\n";
|
||||
echo $e->getMessage();
|
||||
break; // Stop executing further commands
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user