[ 'win', 'UWIN', ], 'mac' => [ 'mac', 'darwin', ], 'linux' => [ 'linux', 'cygwin', 'GNU', 'FreeBSD', 'OpenBSD', 'NetBSD', ], ]; $sysOS = strtolower(PHP_OS); foreach ($osList as $osName => $osSystem) { if (preg_match('/^('.implode('|', $osSystem).')/i', $sysOS)) { return $osName; } } return null; } /** * Get a root directory of EspoCRM. */ public function getRootDir(): string { $bPath = realpath('bootstrap.php'); $rootDir = dirname($bPath); return $rootDir; } /** * Get a PHP binary. */ public function getPhpBinary(): ?string { $path = (new PhpExecutableFinder)->find(); if ($path === false) { return null; } return $path; } /** * Get PHP version (only digits and dots). */ public static function getPhpVersion(): string { $version = phpversion(); $matches = null; if (preg_match('/^[0-9\.]+[0-9]/', $version, $matches)) { return $matches[0]; } return $version; } /** * @return string|false */ public function getPhpParam(string $name) { return ini_get($name); } /** * Whether a PHP extension is loaded. */ public function hasPhpExtension(string $name): bool { return extension_loaded($name); } /** * @deprecated Use `hasPhpExtension`. */ public function hasPhpLib(string $name): bool { return extension_loaded($name); } /** * Get a process PID. */ public static function getPid(): ?int { if (function_exists('getmypid')) { return getmypid(); } return null; } public static function isProcessActive(?int $pid): bool { if ($pid === null) { return false; } if (!self::isPosixSupported()) { return false; } if (posix_getsid($pid) === false) { return false; } return true; } public static function isPosixSupported(): bool { return function_exists('posix_getsid'); } }