From e6f466a13d5904cea03f6ca5e70b3f980ac7c812 Mon Sep 17 00:00:00 2001 From: Bozhidar Date: Wed, 15 May 2024 15:48:45 +0300 Subject: [PATCH] update --- web/app/Filament/Pages/PHPInfo.php | 28 ++++++++++++++++++- .../views/filament/pages/php-info.blade.php | 7 ++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/web/app/Filament/Pages/PHPInfo.php b/web/app/Filament/Pages/PHPInfo.php index a0b968d..4e9bf37 100644 --- a/web/app/Filament/Pages/PHPInfo.php +++ b/web/app/Filament/Pages/PHPInfo.php @@ -21,6 +21,29 @@ class PHPInfo extends Page } + public function getInstalledPHPModules($phpVersion) + { + $modules = []; + $getModules = shell_exec('php' . $phpVersion . ' -m'); + if (!empty($getModules)) { + $getModules = explode("\n", $getModules); + if (is_array($getModules)) { + $getModules = array_filter($getModules); + foreach ($getModules as $module) { + if ($module == '[PHP Modules]') { + continue; + } + if ($module == '[Zend Modules]') { + continue; + } + $modules[] = $module; + } + $modules = array_unique($modules); + } + } + return $modules; + } + protected function getViewData(): array { $installedPHPVersions = []; @@ -35,7 +58,10 @@ class PHPInfo extends Page $phpVersion = str_replace('php', '', $phpVersion); $phpVersion = str_replace('.', '', $phpVersion); $phpVersion = substr($phpVersion, 0, 1) . '.' . substr($phpVersion, 1); - $installedPHPVersions[] = $phpVersion; + $installedPHPVersions[] = [ + 'version' => $phpVersion, + 'modules' => $this->getInstalledPHPModules($phpVersion) ?? 'No modules found.', + ]; } } } diff --git a/web/resources/views/filament/pages/php-info.blade.php b/web/resources/views/filament/pages/php-info.blade.php index d497ccf..63cd89a 100644 --- a/web/resources/views/filament/pages/php-info.blade.php +++ b/web/resources/views/filament/pages/php-info.blade.php @@ -13,7 +13,12 @@ - PHP {{ $phpVersion }} + PHP {{ $phpVersion['version'] }} + +
+ @foreach($phpVersion['modules'] as $phpModule) + {{ $phpModule }}{{ !$loop->last ? ', ' : '' }} + @endforeach
@endforeach