wezom-agency/browserizr 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

wezom-agency/browserizr

Composer 安装命令:

composer require wezom-agency/browserizr

包简介

Browserizr is tiny library, that detects your browser

README 文档

README

license composer npm WezomAgency

Browserizr is tiny library, that detects your browser
with testing $_SERVER['HTTP_USER_AGENT'].

that is PHP port of the JavaScript library WezomAgency/Browserizr
with several limitations...

Install

composer require wezom-agency/browserizr

Prev versions

please read:

API

List of built-in tests

  1. Browserizr::detect()->isAndroid()
  2. Browserizr::detect()->isAndroid3()
  3. Browserizr::detect()->isAndroid4()
  4. Browserizr::detect()->isAndroid5()
  5. Browserizr::detect()->isAndroid6()
  6. Browserizr::detect()->isAndroid7()
  7. Browserizr::detect()->isAndroid8()
  8. Browserizr::detect()->isBlackberry()
  9. Browserizr::detect()->isBlackberry10()
  10. Browserizr::detect()->isEdge()
  11. Browserizr::detect()->isEdgeAndroid()
  12. Browserizr::detect()->isEdgeIOS()
  13. Browserizr::detect()->isIE()
  14. Browserizr::detect()->isIE8()
  15. Browserizr::detect()->isIE9()
  16. Browserizr::detect()->isIE10()
  17. Browserizr::detect()->isIE11()
  18. Browserizr::detect()->isIPad()
  19. Browserizr::detect()->isIPod()
  20. Browserizr::detect()->isIPhone()
  21. Browserizr::detect()->isWindowsPhone()
  22. Browserizr::detect()->isMoz()
  23. Browserizr::detect()->isOpera()
  24. Browserizr::detect()->isSafari()
  25. Browserizr::detect()->isChrome()
  26. Browserizr::detect()->isMobile()
  27. Browserizr::detect()->isDesktop()

Usage examples:

<?php

use WezomAgency\Browserizr;

?>
<?php if (Browserizr::detect()->isChrome()) { ?>
    <div class="alert">Chrome is here, baby!!!</div>
<?php } ?>

Generate css classes

Browserizr::detect()->cssClasses($tests, $cssPrefix = "", $toString = true): array|string

Create string with CSS classes

Parameters:

Name Data type Default value Description
$tests string[] array of wanted tests, each name - test name without is prefix
$cssPrefix string "" custom prefix for CSS class name
$toString bool true implode resulted array and return as string;

Usage examples:

<?php

use WezomAgency\Browserizr;

?>
<!DOCTYPE html>
<html class="<?= Browserizr::detect()->cssClasses(['Mobile', 'Desktop']); ?>">
    <head>...</head>
    <body>...</body>
</html>

<!-- render output -->
<html class="is-mobile is-not-desktop"><!-- if mobile device -->
<html class="is-not-mobile is-desktop"><!-- if desktop -->
<?php

use WezomAgency\Browserizr;

?>
<!DOCTYPE html>
<html class="<?= Browserizr::detect()->cssClasses(['Mobile', 'Desktop'], 'browserizr-'); ?>">
    <head>...</head>
    <body>...</body>
</html>

<!-- render output -->
<html class="browserizr-is-mobile browserizr-is-not-desktop"><!-- if mobile device -->
<html class="browserizr-is-not-mobile browserizr-is-desktop"><!-- if desktop -->
<?php

use WezomAgency\Browserizr;

$myCssClasses = Browserizr::detect()->cssClasses(['Mobile', 'Desktop'], '', false);
// ... work with array, e.g. array_push() or array_combine() or whatever you want

?>

Set custom UserAgent

by default Browserizr use $_SERVER['HTTP_USER_AGENT']
you can set own string for UserAgent.

Note
if you needed to change agent - you must do it before use the Browserizr tests

<?php

use WezomAgency\Browserizr;

Browserizr::detect()->setUserAgent('my own UserAgent string');

// then can test your browser correctly
var_export(Browserizr::detect()->isWindowsPhone());

wezom-agency/browserizr 适用场景与选型建议

wezom-agency/browserizr 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.55k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 10 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 wezom-agency/browserizr 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 5.55k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 11
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-10-19