tivie/php-os-detector

一个用于检测服务器正在运行的操作系统的小型实用库

1.1.0 2017-10-21 03:33 UTC

This package is not auto-updated.

Last update: 2024-09-14 16:13:37 UTC


README

Latest Stable Version Total Downloads License

一个用于检测服务器正在运行的操作系统的小型PHP实用库。

兼容性

尽管只在PHP 7上进行了测试,但PHP OS Detector应该与PHP 5.3或更高版本兼容

安装

您可以通过克隆git仓库或使用composer来安装它。

Git克隆

git clone https://github.com/tivie/php-os-detector.git

Composer

将这些行添加到您的composer.json中

    {
        "require": {
            "tivie/php-os-detector": "*"
        }
    }

或运行以下命令

php composer.phar require tivie/php-os-detector

使用示例

$os = new \Tivie\OS\Detector();
$kernelName = $os->getKernelName();
if ($os->isUnixLike()) {
    echo "I'm using a Unix like system with kernel $kernelName";
} else if ($os->isWindowsLike()) {
    echo "I'm using a Windows like system with kernel $kernelName";
} else {
    echo "I'm using a non-Unix non-Windows system";
}

贡献

您可以自由地通过分支或提出建议来贡献。

问题跟踪器: https://github.com/tivie/php-os-detector/issues

源代码: https://github.com/tivie/php-os-detector

许可证

命令库在Apache 2.0许可证下发布。有关更多信息,请参阅此存储库中的LICENSE文件https://apache.ac.cn/licenses/LICENSE-2.0.txt