diff --git a/app/Http/Livewire/Php/InstalledVersions.php b/app/Http/Livewire/Php/InstalledVersions.php index a792781..b9d1a8d 100644 --- a/app/Http/Livewire/Php/InstalledVersions.php +++ b/app/Http/Livewire/Php/InstalledVersions.php @@ -3,11 +3,13 @@ namespace App\Http\Livewire\Php; use App\Actions\PHP\InstallNewPHP; +use App\Actions\PHP\InstallPHPExtension; use App\Actions\PHP\UpdatePHPIni; use App\Models\Server; use App\Models\Service; use App\SSHCommands\PHP\GetPHPIniCommand; use App\Traits\RefreshComponentOnBroadcast; +use Exception; use Illuminate\Contracts\View\View; use Livewire\Component; use Throwable; @@ -24,6 +26,10 @@ class InstalledVersions extends Component public string $ini = 'Loading php.ini'; + public ?int $extensionId = null; + + public string $extension = ''; + public function install(string $version): void { app(InstallNewPHP::class)->install($this->server, [ @@ -35,6 +41,7 @@ public function install(string $version): void public function restart(int $id): void { + /** @var Service $service */ $service = Service::query()->findOrFail($id); $service->restart(); @@ -43,6 +50,7 @@ public function restart(int $id): void public function uninstall(): void { + /** @var Service $service */ $service = Service::query()->findOrFail($this->uninstallId); $service->uninstall(); @@ -56,6 +64,7 @@ public function loadIni(int $id): void $this->iniId = $id; $this->ini = 'Loading php.ini'; + /** @var Service $service */ $service = Service::query()->findOrFail($this->iniId); try { @@ -67,6 +76,7 @@ public function loadIni(int $id): void public function saveIni(): void { + /** @var Service $service */ $service = Service::query()->findOrFail($this->iniId); app(UpdatePHPIni::class)->update($service, $this->all()['ini']); @@ -76,10 +86,32 @@ public function saveIni(): void session()->flash('status', 'ini-updated'); } + /** + * @throws Exception + */ + public function installExtension(): void + { + /** @var Service $service */ + $service = Service::query()->findOrFail($this->extensionId); + + app(InstallPHPExtension::class)->handle($service, [ + 'name' => $this->extension, + ]); + + session()->flash('status', 'started-installation'); + } + public function render(): View { + if ($this->extensionId) { + /** @var Service $php */ + $php = Service::query()->findOrFail($this->extensionId); + $installedExtensions = $php->type_data['extensions'] ?? []; + } + return view('livewire.php.installed-versions', [ 'phps' => $this->server->services()->where('type', 'php')->get(), + 'installedExtensions' => $installedExtensions ?? [], ]); } } diff --git a/config/core.php b/config/core.php index 4ecfaa7..a57c999 100755 --- a/config/core.php +++ b/config/core.php @@ -292,11 +292,12 @@ */ 'php_extensions' => [ 'imagick', - 'geoip', 'exif', 'gmagick', 'gmp', 'intl', + 'sqlite3', + 'opcache', ], /* diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 04fec12..4d53459 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -38,7 +38,8 @@ class="left-0 top-0 min-h-screen w-64 flex-none bg-gray-800 dark:bg-gray-800/50 p-3 dark:border-r-2 dark:border-gray-800">