‪TYPO3CMS  10.4
Environment.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\Core\Core;
19 
40 {
45  protected static ‪$supportedCgiServerApis = [
46  'fpm-fcgi',
47  'cgi',
48  'isapi',
49  'cgi-fcgi',
50  'srv', // HHVM with fastcgi
51  ];
52 
56  protected static ‪$cli;
57 
61  protected static ‪$composerMode;
62 
66  protected static ‪$context;
67 
71  protected static ‪$projectPath;
72 
76  protected static ‪$publicPath;
77 
81  protected static ‪$currentScript;
82 
86  protected static ‪$os;
87 
91  protected static ‪$varPath;
92 
96  protected static ‪$configPath;
97 
114  public static function ‪initialize(
116  bool ‪$cli,
117  bool ‪$composerMode,
118  string ‪$projectPath,
119  string ‪$publicPath,
120  string ‪$varPath,
121  string ‪$configPath,
122  string ‪$currentScript,
123  string ‪$os
124  ) {
125  self::$cli = ‪$cli;
126  self::$composerMode = ‪$composerMode;
127  self::$context = ‪$context;
128  self::$projectPath = ‪$projectPath;
129  self::$publicPath = ‪$publicPath;
130  self::$varPath = ‪$varPath;
131  self::$configPath = ‪$configPath;
132  self::$currentScript = ‪$currentScript;
133  self::$os = ‪$os;
134  }
135 
143  public static function ‪getContext(): ‪ApplicationContext
144  {
145  return ‪self::$context;
146  }
147 
154  public static function ‪isComposerMode(): bool
155  {
156  return ‪self::$composerMode;
157  }
158 
164  public static function ‪isCli(): bool
165  {
166  return ‪self::$cli;
167  }
168 
179  public static function ‪getProjectPath(): string
180  {
181  return ‪self::$projectPath;
182  }
183 
190  public static function ‪getPublicPath(): string
191  {
193  }
194 
202  public static function ‪getVarPath(): string
203  {
204  return ‪self::$varPath;
205  }
206 
220  public static function ‪getConfigPath(): string
221  {
222  return ‪self::$configPath;
223  }
224 
230  public static function ‪getCurrentScript(): string
231  {
233  }
234 
246  public static function ‪getLabelsPath(): string
247  {
248  if (self::$publicPath === self::$projectPath) {
249  return ‪self::getPublicPath() . '/typo3conf/l10n';
250  }
251  return ‪self::getVarPath() . '/labels';
252  }
253 
260  public static function ‪getBackendPath(): string
261  {
262  return ‪self::getPublicPath() . '/typo3';
263  }
264 
271  public static function ‪getFrameworkBasePath(): string
272  {
273  return ‪self::getPublicPath() . '/typo3/sysext';
274  }
275 
281  public static function ‪getExtensionsPath(): string
282  {
283  return ‪self::getPublicPath() . '/typo3conf/ext';
284  }
285 
292  public static function ‪getLegacyConfigPath(): string
293  {
294  return ‪self::getPublicPath() . '/typo3conf';
295  }
296 
302  public static function ‪isWindows(): bool
303  {
304  return self::$os === 'WINDOWS';
305  }
306 
312  public static function ‪isUnix(): bool
313  {
314  return self::$os === 'UNIX';
315  }
316 
322  public static function ‪isRunningOnCgiServer(): bool
323  {
324  return in_array(PHP_SAPI, self::$supportedCgiServerApis, true);
325  }
326 
327  public static function ‪usesCgiFixPathInfo(): bool
328  {
329  return !empty(ini_get('cgi.fix_pathinfo'));
330  }
331 
337  public static function ‪toArray(): array
338  {
339  return [
340  'context' => (string)self::getContext(),
341  'cli' => ‪self::isCli(),
342  'projectPath' => ‪self::getProjectPath(),
343  'publicPath' => ‪self::getPublicPath(),
344  'varPath' => ‪self::getVarPath(),
345  'configPath' => ‪self::getConfigPath(),
346  'currentScript' => ‪self::getCurrentScript(),
347  'os' => ‪self::isWindows() ? 'WINDOWS' : 'UNIX'
348  ];
349  }
350 }
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static string getPublicPath()
Definition: Environment.php:180
‪TYPO3\CMS\Core\Core\Environment\$composerMode
‪static bool $composerMode
Definition: Environment.php:58
‪TYPO3\CMS\Core\Core\Environment\isRunningOnCgiServer
‪static bool isRunningOnCgiServer()
Definition: Environment.php:312
‪TYPO3\CMS\Core\Core\Environment\getLabelsPath
‪static string getLabelsPath()
Definition: Environment.php:236
‪TYPO3\CMS\Core\Core\ApplicationContext
Definition: ApplicationContext.php:37
‪TYPO3\CMS\Core\Core\Environment\isUnix
‪static bool isUnix()
Definition: Environment.php:302
‪TYPO3\CMS\Core\Core\Environment\$currentScript
‪static string $currentScript
Definition: Environment.php:74
‪TYPO3\CMS\Core\Core\Environment\isWindows
‪static bool isWindows()
Definition: Environment.php:292
‪TYPO3\CMS\Core\Core\Environment\getCurrentScript
‪static string getCurrentScript()
Definition: Environment.php:220
‪TYPO3\CMS\Core\Core\Environment\$projectPath
‪static string $projectPath
Definition: Environment.php:66
‪TYPO3\CMS\Core\Core\Environment\$cli
‪static bool $cli
Definition: Environment.php:54
‪TYPO3\CMS\Core\Core\Environment\getFrameworkBasePath
‪static string getFrameworkBasePath()
Definition: Environment.php:261
‪TYPO3\CMS\Core\Core\Environment\getContext
‪static ApplicationContext getContext()
Definition: Environment.php:133
‪TYPO3\CMS\Core\Core\Environment\getProjectPath
‪static string getProjectPath()
Definition: Environment.php:169
‪TYPO3\CMS\Core\Core\Environment\$os
‪static string $os
Definition: Environment.php:78
‪TYPO3\CMS\Core\Core\Environment\usesCgiFixPathInfo
‪static usesCgiFixPathInfo()
Definition: Environment.php:317
‪TYPO3\CMS\Core\Core\Environment\initialize
‪static initialize(ApplicationContext $context, bool $cli, bool $composerMode, string $projectPath, string $publicPath, string $varPath, string $configPath, string $currentScript, string $os)
Definition: Environment.php:104
‪TYPO3\CMS\Core\Core\Environment\getBackendPath
‪static string getBackendPath()
Definition: Environment.php:250
‪TYPO3\CMS\Core\Core\Environment\$publicPath
‪static string $publicPath
Definition: Environment.php:70
‪TYPO3\CMS\Core\Core\Environment\$varPath
‪static string $varPath
Definition: Environment.php:82
‪TYPO3\CMS\Core\Core\Environment\isComposerMode
‪static bool isComposerMode()
Definition: Environment.php:144
‪TYPO3\CMS\Core\Core\Environment\toArray
‪static array toArray()
Definition: Environment.php:327
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:40
‪TYPO3\CMS\Core\Core
Definition: ApplicationContext.php:16
‪TYPO3\CMS\Core\Core\Environment\$context
‪static ApplicationContext $context
Definition: Environment.php:62
‪TYPO3\CMS\Core\Core\Environment\$supportedCgiServerApis
‪static array $supportedCgiServerApis
Definition: Environment.php:44
‪TYPO3\CMS\Core\Core\Environment\getConfigPath
‪static string getConfigPath()
Definition: Environment.php:210
‪TYPO3\CMS\Core\Core\Environment\isCli
‪static bool isCli()
Definition: Environment.php:154
‪TYPO3\CMS\Core\Core\Environment\$configPath
‪static string $configPath
Definition: Environment.php:86
‪TYPO3\CMS\Core\Core\Environment\getLegacyConfigPath
‪static string getLegacyConfigPath()
Definition: Environment.php:282
‪TYPO3\CMS\Core\Core\Environment\getVarPath
‪static string getVarPath()
Definition: Environment.php:192
‪TYPO3\CMS\Core\Core\Environment\getExtensionsPath
‪static string getExtensionsPath()
Definition: Environment.php:271