mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-19 22:14:45 +02:00

* Fix these * Update phpstan * Transform these into their identifiers instead * Fix custom rule * License is wrong * Update these * Pint fixes * Fix this * Consolidate these * Never supported PHP 7 * Better evaluation * Fixes * Don’t need ignore * Replace trait with service * Subusers are simply the many to many relationship between Servers and Users * Adjust to remove ignores * Use new query builder instead! * wip * Update composer * Quick fixes * Use realtime facade * Small fixes * Convert to static to avoid new * Update to statics * Don’t modify protected properties directly * Run pint * Change to correct method * Give up and use the facade * Make sure this route is available * Filament hasn’t been loaded yet * This can be readonly * Typehint * These are no longer used * Quick fixes * Need doc block help * Always true * We use caddy with docker * Pint * Fix phpstan issues * Remove unused import --------- Co-authored-by: MartinOscar <40749467+RMartinOscar@users.noreply.github.com>
91 lines
3.8 KiB
PHP
91 lines
3.8 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Installer\Steps;
|
|
|
|
use Filament\Forms\Components\Placeholder;
|
|
use Filament\Forms\Components\Section;
|
|
use Filament\Forms\Components\Wizard\Step;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Support\Exceptions\Halt;
|
|
|
|
class RequirementsStep
|
|
{
|
|
public const MIN_PHP_VERSION = '8.2';
|
|
|
|
public static function make(): Step
|
|
{
|
|
$compare = version_compare(phpversion(), self::MIN_PHP_VERSION);
|
|
$correctPhpVersion = $compare >= 0;
|
|
|
|
$fields = [
|
|
Section::make('PHP Version')
|
|
->description(self::MIN_PHP_VERSION . ' or newer')
|
|
->icon($correctPhpVersion ? 'tabler-check' : 'tabler-x')
|
|
->iconColor($correctPhpVersion ? 'success' : 'danger')
|
|
->schema([
|
|
Placeholder::make('')
|
|
->content('Your PHP Version is ' . PHP_VERSION . '.'),
|
|
]),
|
|
];
|
|
|
|
$phpExtensions = [
|
|
'BCMath' => extension_loaded('bcmath'),
|
|
'cURL' => extension_loaded('curl'),
|
|
'GD' => extension_loaded('gd'),
|
|
'intl' => extension_loaded('intl'),
|
|
'mbstring' => extension_loaded('mbstring'),
|
|
'MySQL' => extension_loaded('pdo_mysql'),
|
|
'SQLite3' => extension_loaded('pdo_sqlite'),
|
|
'XML' => extension_loaded('xml'),
|
|
'Zip' => extension_loaded('zip'),
|
|
];
|
|
$allExtensionsInstalled = !in_array(false, $phpExtensions);
|
|
|
|
$fields[] = Section::make('PHP Extensions')
|
|
->description(implode(', ', array_keys($phpExtensions)))
|
|
->icon($allExtensionsInstalled ? 'tabler-check' : 'tabler-x')
|
|
->iconColor($allExtensionsInstalled ? 'success' : 'danger')
|
|
->schema([
|
|
Placeholder::make('')
|
|
->content('All needed PHP Extensions are installed.')
|
|
->visible($allExtensionsInstalled),
|
|
Placeholder::make('')
|
|
->content('The following PHP Extensions are missing: ' . implode(', ', array_keys($phpExtensions, false)))
|
|
->visible(!$allExtensionsInstalled),
|
|
]);
|
|
|
|
$folderPermissions = [
|
|
'Storage' => substr(sprintf('%o', fileperms(base_path('storage/'))), -4) >= 755,
|
|
'Cache' => substr(sprintf('%o', fileperms(base_path('bootstrap/cache/'))), -4) >= 755,
|
|
];
|
|
$correctFolderPermissions = !in_array(false, $folderPermissions);
|
|
|
|
$fields[] = Section::make('Folder Permissions')
|
|
->description(implode(', ', array_keys($folderPermissions)))
|
|
->icon($correctFolderPermissions ? 'tabler-check' : 'tabler-x')
|
|
->iconColor($correctFolderPermissions ? 'success' : 'danger')
|
|
->schema([
|
|
Placeholder::make('')
|
|
->content('All Folders have the correct permissions.')
|
|
->visible($correctFolderPermissions),
|
|
Placeholder::make('')
|
|
->content('The following Folders have wrong permissions: ' . implode(', ', array_keys($folderPermissions, false)))
|
|
->visible(!$correctFolderPermissions),
|
|
]);
|
|
|
|
return Step::make('requirements')
|
|
->label('Server Requirements')
|
|
->schema($fields)
|
|
->afterValidation(function () use ($correctPhpVersion, $allExtensionsInstalled, $correctFolderPermissions) {
|
|
if (!$correctPhpVersion || !$allExtensionsInstalled || !$correctFolderPermissions) {
|
|
Notification::make()
|
|
->title('Some requirements are missing!')
|
|
->danger()
|
|
->send();
|
|
|
|
throw new Halt('Some requirements are missing');
|
|
}
|
|
});
|
|
}
|
|
}
|