phluxcp/operating-system
Composer 安装命令:
composer require phluxcp/operating-system
包简介
A PHP component to detect the running OS name, version and family.
README 文档
README
phluxcp/operating-system
A PHP framework-agnostic component to detect the running OS name, version and family. It can also be installed globally to use a binary to show your operating system.
Warning
This package is in early development stage and is not ready for production use. It is not tested yet, so use it at your own risk.
Installation
composer require phluxcp/operating-system
Usage
// Instance of Phlux\Component\OperatingSystem\System\SystemInterface $system = Phlux\Component\OperatingSystem\detect();
Each OS instance class can (and should) extend a parent OS class if it is a derivative.
For example, you can detect if the running system is Ubuntu by checking the instance of the class:
use Phlux\Component\OperatingSystem; $system = OperatingSystem\detect(); // Ubuntu instance $system instanceof OperatingSystem\System\Ubuntu; // true
At the same time, you can check if you are running a Debian based OS, even if it is a derivated OS.
This can be very useful if you want to check between major Linux distributions:
use Phlux\Component\OperatingSystem; $system = OperatingSystem\detect(); // Ubuntu instance if ($system instanceof OperatingSystem\System\Debian) { // Do something if OS is Debian, Ubuntu, LMDE, Elementary... } elseif ($system instanceof OperatingSystem\System\Fedora) { // Do something if OS is Fedora, RHEL, CentOS... }
Adding new detectors
If you need to add a new detector for an obscure case, OS, or cannot wait for a pull request to get merged you can add
more detectors when instantiating the Detector class:
use Phlux\Component\OperatingSystem; // Create a new detector instance with custom detectors... $detector = new OperatingSystem\Detector( new OperatingSystem\Filesystem\Amp(), [ \MyNamespace\OperatingSystem\ObscureOS::class, // You can add detectors as you want if they all implements Phlux\Component\OperatingSystem\System\SystemInterface ], ); // ...or add to the default detectors from the constructor... $detector = new OperatingSystem\Detector( new OperatingSystem\Filesystem\Amp(), [ ...OperatingSystem\Detector::DEFAULT_DETECTORS, // Include default detectors \MyNamespace\OperatingSystem\ObscureOS::class, // You can add detectors as you want if they all implements Phlux\Component\OperatingSystem\System\SystemInterface ], ); // ...or add them later $detector = new OperatingSystem\Detector(new OperatingSystem\Filesystem\Amp()); $detector->addSystem(\MyNamespace\OperatingSystem\ObscureOS::class);
Implement SystemInterface if the OS is not a derivated distribution...
use Phlux\Component\OperatingSystem\System\SystemInterface; class ObscureOS implements SystemInterface { // ... }
...or just extend another OS
use Phlux\Component\OperatingSystem\System\Debian; class ObscureOS extends Debian { // ... }
Binary usage
Besides phluxcp/operating-system is primarily intended to be programmatically used, it can be used to play as a binary in a global installation.
Simply run
composer global require phluxcp/operating-system
and run detect-operating-system
phluxcp/operating-system 适用场景与选型建议
phluxcp/operating-system 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 07 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 phluxcp/operating-system 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 phluxcp/operating-system 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-27