A small PHP utility library that detects the OS the server is running on.
Although only tested in PHP 7, PHP OS Detector should be compatible with PHP 5.3 or greater
You can install it by cloning the git repository or using composer.
git clone https://github.com/tivie/php-os-detector.git
Add these lines to your composer.json:
{
"require": {
"tivie/php-os-detector": "*"
}
}
or run the following command:
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";
}
Feel free to contribute by forking or making suggestions.
Issue tracker: https://github.com/tivie/php-os-detector/issues
Source code: https://github.com/tivie/php-os-detector
Command Library is released under Apache 2.0 license. For more information, please consult the LICENSE file in this repository or http://www.apache.org/licenses/LICENSE-2.0.txt.