定制 invoke/browser 二次开发

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

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

invoke/browser

Composer 安装命令:

composer require invoke/browser

包简介

A small class to detect the browser and the operating system

README 文档

README

A very simple class that takes in a user agent string and returns the browser name (Firefox, Chrome, Opera, etc.) and also the Operating System (Mac, Windows, Android, etc.).

Reasons

Firstly, you should not use browser sniffing for fearture detection, use Modernizr.

We mainly use this for style tweaks between different browsers. Or sometimes you may need to add a little script (differences in keystroke handling can be difficult to feature detect) or tweak on a specific platform combination and so you might do a check to see if that makes sense.

The results are pretty crude. We only return internet-explorer if any verison of IE is found. There is no version information.

For the platform, we only return that operation system. This means all iOS devices (iPad, iPhone, iPod) would only return ios.

If you need to know specifics about the device, use media queries.

Support

Platforms

  • Linux
  • iOS
  • Mac
  • Windows
  • Android
  • Blackberry

Browsers

  • MSIE
  • UC Browser
  • Trident
  • Vivaldi
  • Firefox
  • Chrome
  • Opera
  • Opera Mini
  • Safari

Usage

Methods

getBrowser() // returns the string for the browser
getPlatform() // returns the platform for the browser
isMobile() // returns true for android and ios platforms (except iPad)
isDesktop() // returns the opposite of isMobile()

Properties

<?php

$browser = new Browser($_SERVER['HTTP_USER_AGENT']);
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Browser Class</title>
  <style>
    body.google-chrome.mac {
      background: red;
    }
  </style>
</head>
<body class="<?php echo $browser->browser . ' ' . $browser->platform ?>">
  <!-- content -->
</body>
</html>

Results for Chrome on a Macbook:

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Browser Class</title>
  <style>
    /* the body would now be red */
    body.google-chrome.mac {
      background: red;
    }
  </style>
</head>
<body class="google-chrome mac">
  <!-- content -->
</body>
</html>

统计信息

  • 总下载量: 31
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 4
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-11-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固