‪TYPO3CMS  ‪main
WebserverType.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
18 namespace ‪TYPO3\CMS\Install;
19 
20 use Psr\Http\Message\ServerRequestInterface;
21 
25 enum ‪WebserverType: string
26 {
27  case Apache = 'apache';
28  case MicrosoftInternetInformationServer = 'iis';
29  case Other = 'other';
30 
31  public static function ‪fromRequest(ServerRequestInterface $request): self
32  {
33  return self::fromType((string)($request->getServerParams()['SERVER_SOFTWARE'] ?? ''));
34  }
35 
36  public static function fromType(string $type): self
37  {
38  if ($type === 'apache' || str_starts_with($type, 'Apache')) {
39  return self::Apache;
40  }
41  if ($type === 'iis' || str_starts_with($type, 'Microsoft-IIS')) {
42  return self::MicrosoftInternetInformationServer;
43  }
44 
45  return self::Other;
46  }
47 
51  public static function getDescriptions(): array
52  {
53  return [
54  self::Apache->value => 'Apache',
55  self::MicrosoftInternetInformationServer->value => 'Microsoft IIS',
56  self::Other->value => 'Other (use for anything else)',
57  ];
58  }
59 
60  public function isApacheServer(): bool
61  {
62  return $this === self::Apache;
63  }
64 
65  public function isMicrosoftInternetInformationServer(): bool
66  {
67  return $this === self::MicrosoftInternetInformationServer;
68  }
69 }
‪TYPO3\CMS\Install\WebserverType
‪WebserverType
Definition: WebserverType.php:26
‪TYPO3\CMS\Install
Definition: LegacyClassesForIde.php:22
‪TYPO3\CMS\Core\Http\fromRequest
‪@ fromRequest
Definition: ApplicationType.php:66