This commit is contained in:
Saeed Vaziry
2023-07-02 12:47:50 +02:00
commit 5c72f12490
825 changed files with 41659 additions and 0 deletions

View File

@ -0,0 +1,30 @@
<?php
namespace App\Http\Livewire\Php;
use App\Models\Server;
use App\Traits\RefreshComponentOnBroadcast;
use Illuminate\Contracts\View\View;
use Livewire\Component;
class DefaultCli extends Component
{
use RefreshComponentOnBroadcast;
public Server $server;
public function change(string $version): void
{
$this->server->php($version)->handler()->setDefaultCli();
$this->refreshComponent([]);
}
public function render(): View
{
return view('livewire.php.default-cli', [
'defaultPHP' => $this->server->defaultService('php'),
'phps' => $this->server->services()->where('type', 'php')->get(), //
]);
}
}

View File

@ -0,0 +1,85 @@
<?php
namespace App\Http\Livewire\Php;
use App\Actions\PHP\InstallNewPHP;
use App\Actions\PHP\UpdatePHPIni;
use App\Models\Server;
use App\Models\Service;
use App\SSHCommands\GetPHPIniCommand;
use App\Traits\RefreshComponentOnBroadcast;
use Illuminate\Contracts\View\View;
use Livewire\Component;
use Throwable;
class InstalledVersions extends Component
{
use RefreshComponentOnBroadcast;
public Server $server;
public int $uninstallId;
public int $iniId;
public string $ini = 'Loading php.ini';
public function install(string $version): void
{
app(InstallNewPHP::class)->install($this->server, [
'version' => $version,
]);
$this->refreshComponent([]);
}
public function restart(int $id): void
{
$service = Service::query()->findOrFail($id);
$service->restart();
$this->refreshComponent([]);
}
public function uninstall(): void
{
$service = Service::query()->findOrFail($this->uninstallId);
$service->uninstall();
$this->refreshComponent([]);
$this->dispatchBrowserEvent('confirmed', true);
}
public function loadIni(int $id): void
{
$this->iniId = $id;
$this->ini = 'Loading php.ini';
$service = Service::query()->findOrFail($this->iniId);
try {
$this->ini = $service->server->ssh()->exec(new GetPHPIniCommand($service->version));
} catch (Throwable) {
//
}
}
public function saveIni(): void
{
$service = Service::query()->findOrFail($this->iniId);
app(UpdatePHPIni::class)->update($service, $this->all()['ini']);
$this->refreshComponent([]);
session()->flash('status', 'ini-updated');
}
public function render(): View
{
return view('livewire.php.installed-versions', [
'phps' => $this->server->services()->where('type', 'php')->get(),
]);
}
}