wezom-agency/browserizr
Composer 安装命令:
composer require wezom-agency/browserizr
包简介
Browserizr is tiny library, that detects your browser
README 文档
README
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
Browserizr::detect()->isAndroid()Browserizr::detect()->isAndroid3()Browserizr::detect()->isAndroid4()Browserizr::detect()->isAndroid5()Browserizr::detect()->isAndroid6()Browserizr::detect()->isAndroid7()Browserizr::detect()->isAndroid8()Browserizr::detect()->isBlackberry()Browserizr::detect()->isBlackberry10()Browserizr::detect()->isEdge()Browserizr::detect()->isEdgeAndroid()Browserizr::detect()->isEdgeIOS()Browserizr::detect()->isIE()Browserizr::detect()->isIE8()Browserizr::detect()->isIE9()Browserizr::detect()->isIE10()Browserizr::detect()->isIE11()Browserizr::detect()->isIPad()Browserizr::detect()->isIPod()Browserizr::detect()->isIPhone()Browserizr::detect()->isWindowsPhone()Browserizr::detect()->isMoz()Browserizr::detect()->isOpera()Browserizr::detect()->isSafari()Browserizr::detect()->isChrome()Browserizr::detect()->isMobile()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 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 5.55k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-10-19