array( 'win', 'UWIN', ), 'mac' => array( 'mac', 'darwin', ), 'linux' => array( '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 false; } /** * Get root directory of EspoCRM * * @return string */ public function getRootDir() { $bPath = realpath('bootstrap.php'); $rootDir = dirname($bPath); return $rootDir; } /** * Deprecated. Use getPhpBinary() */ public function getPhpBin() { return $this->getPhpBinary(); } /** * Get PHP binary * * @return string */ public function getPhpBinary() { return (new PhpExecutableFinder)->find(); } /** * Get php version (only digits and dots) * * @return string */ public static function getPhpVersion() { $version = phpversion(); if (preg_match('/^[0-9\.]+[0-9]/', $version, $matches)) { return $matches[0]; } return $version; } public function getPhpParam($name) { return ini_get($name); } public function hasPhpLib($name) { return extension_loaded($name); } public static function getPid() { if (function_exists('getmypid')) { return getmypid(); } } public static function isProcessActive($pid) { if (empty($pid)) return false; if (!self::isPosixSupported()) return false; if (posix_getsid($pid) === false) return false; return true; } public static function isPosixSupported() { return function_exists('posix_getsid'); } }