定制 loophp/phposinfo 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

loophp/phposinfo

Composer 安装命令:

composer require loophp/phposinfo

包简介

Try to guess the host operating system.

README 文档

README

Latest Stable Version GitHub stars Total Downloads GitHub Workflow Status Scrutinizer code quality Type Coverage Code Coverage License Donate!

PHP OS Info

Description

Get information of the current operating system where PHP is running on.

Information that you can retrieve are:

  • Operating system name
  • Operating system family
  • Machine UUID

There are many packages that does that already, but most of them are based on the use of the variable PHP_OS that contains the operating system name PHP was built on, from php.net:

 The operating system PHP was built for.

However, PHP_OS might be sometimes not very accurate, then using php_uname() might be a better fit for detecting the operating system, we only use it as a fallback.

This library uses php_uname() and a static list of existing operating systems, and then from there, tries to deduct the operating system family.

From PHP 7.2, the variable PHP_OS_FAMILY was added and based on the definition from php.net:

 The operating system family PHP was built for.
 Either of 'Windows', 'BSD', 'Darwin', 'Solaris', 'Linux' or 'Unknown'.

So once again, if you're using a PHP which is cross compiled, using those constant is a bad idea.

Requirements

  • PHP >= 7.1.3

Installation

composer require loophp/phposinfo

Usage

<?php

include 'vendor/autoload.php';

use loophp\phposinfo\OsInfo;
use loophp\phposinfo\Enum\Family;
use loophp\phposinfo\Enum\Os;

// Register constants if they do not exists:
// * PHP_OS_FAMILY
// * PHP_OS
// * PHPOSINFO_OS_FAMILY
// * PHPOSINFO_OS
OsInfo::register();

// Get the OS name.
OsInfo::os();

// Get the OS family.
OsInfo::family();

// Check if the OS is Unix based.
OsInfo::isUnix();

// Check if the OS is Apple based.
OsInfo::isApple();

// Check if the OS is Windows based.
OsInfo::isWindows();

// Check the OS version.
OsInfo::version();

// Check the OS release.
OsInfo::release();

// Check if the OS Family is Family::UNIX_ON_WINDOWS.
OsInfo::isFamily(Family::UNIX_ON_WINDOWS);

// Check if the OS is Os::FREEBSD.
OsInfo::isOs(Os::FREEBSD);

// Check if the OS is Windows.
OsInfo::isOs('windows');

// Check if the OS family is darwin.
OsInfo::isFamily('darwin');

// Get the machine UUID.
OsInfo::uuid();

Code quality, tests and benchmarks

Every time changes are introduced into the library, Github actions are setup to test the library against different operating systems and PHP versions.

The library has tests written with PHPSpec. Feel free to check them out in the spec directory. Run composer phpspec to trigger the tests.

Before each commit some inspections are executed with GrumPHP, run ./vendor/bin/grumphp run to check manually.

PHPInfection is used to ensure that your code is properly tested, run composer infection to test your code.

Contributing

Feel free to contribute by sending pull requests. We are a usually very responsive team and we will help you going through your pull request from the beginning to the end.

For some reasons, if you can't contribute to the code and willing to help, sponsoring is a good, sound and safe way to show us some gratitude for the hours we invested in this package.

Sponsor me on Github and/or any of the contributors.

Changelog

See CHANGELOG.md for a changelog based on git commits.

For more detailed changelogs, please check the release changelogs.

loophp/phposinfo 适用场景与选型建议

loophp/phposinfo 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.02M 次下载、GitHub Stars 达 6, 最近一次更新时间为 2021 年 03 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「operating system detection」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 loophp/phposinfo 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 loophp/phposinfo 我们能提供哪些服务?
定制开发 / 二次开发

基于 loophp/phposinfo 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 7.02M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 21
  • 依赖项目数: 9
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-03-21