承接 lexinzector/aboutguest 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

lexinzector/aboutguest

Composer 安装命令:

composer require lexinzector/aboutguest

包简介

User information in PHP - IP, browser, operating system, robot

README 文档

README

User information in PHP - IP, browser, operating system, robot

Provides

  • browser name
  • browser version
  • operating system name
  • operating system version/kernel
  • visitor IP
  • check: whether the user has logged in from a browser
  • check: whether the user is logged in from a mobile device
  • name of brand/OS/browser of mobile phone, smartphone, tablet
  • check: whether the visitor is a search engine robot
  • which search engine does the robot belong to

How the PHP class works to determine visitor data by user-agent

From the arrays folder, associative arrays are loaded that contain abbreviations or short names of browsers, operating systems or robots that appear in the user-agent line that we receive from the browser. After receiving the data, all methods that have the set_ prefix are dynamically called and fill the class variables, because only they are public and can be taken out of the scope of the class.

Requirements

PHP >= 5.6.0

Installation

run in console:

composer require lexinzector/aboutguest

Methods

$this->load($file_and_array_name)

Loader. This method loads arrays from the arrays folder and assigns them to the variable specified in the value of the $file_and_array_name attribute, this attribute is also the name of the file from the arrays folder.

$this->set_ip()

Returns a value from the $_SERVER array with the REMOTE_ADDR key, as you know $_SERVER['REMOTE_ADDR'] is the user's IP that is accessible to the browser.

$this->set_browser()

array file: arrays / browsers.php After the $this->load method has loaded the arrays, this method will work with the array from the $this->browsers object. Once it finds a match between the array key and the contents of the string in $this->agent, it assigns the $this->browser object the value of the key in the $this->browsers array. Also, this method also assigns the browser version in $this->version. Since the browser has already found a match, there is no doubt that the user came from the browser and did not access the site through a script. Set $this->is_browser to True;

$this->set_operating_system()

array file: arrays / operating_systems.php It works in the same way as the $this->set_browser method, except that it uses the $this->operating_systems object as an array to check for a match, which received the array from the arrays/operating_systems.php file after executing the $this->load() method. Unfortunately, browsers are not so active in dealing with the version of the operating system and sometimes you can get strange numbers instead of the version. So be careful when you use $this->os_version. The name of the operating system is contained in $this->operating_system (not to be confused with $this->os_version)

$this->set_robot()

array file: arrays / robots.php We check if the site visitor is not a search engine robot. If he is a robot then the value for $this->is_robot will be TRUE; the value $this->robot will contain the name of the search engine that launched the robot on the site (Google Bot, Yandex Bot, Rambler Bot...)

$this->set_mobile()

array file: arrays / mobiles.php It works similarly to the $this->set_operating_system() method, only it assigns the name of the phone brand to the $this->mobile object and the value of $this->is_mobile will be TRUE if logged in from a mobile phone, smartphone or tablet.

Example

use \Lexinzector\AboutGuest\AboutGuest;

// useragent autodetection
$AboutGuest = new AboutGuest;
// custom useragent
$useragent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36';
$AboutGuest = new AboutGuest($useragent);

echo 'User Agent: ' . $AboutGuest->agent . '<br />';
echo 'IP: ' . $AboutGuest->ip . '<br />';
echo 'Browser: ' . $AboutGuest->browser . '<br />';
echo 'Browser version: ' . $AboutGuest->version . '<br />';
echo 'Operating System: ' . $AboutGuest->operating_system . '<br />';
echo 'OS version: ' . $AboutGuest->os_version . '<br />';
echo 'I am a robot? ' . $AboutGuest->is_robot . '<br />';
echo 'Robot belongs: ' . $AboutGuest->robot . '<br />';
echo 'Logged in from a mobile phone? ' . $AboutGuest->is_mobile . '<br />';
echo 'Mobile phone: ' . $AboutGuest->mobile . '<br />';

lexinzector/aboutguest 适用场景与选型建议

lexinzector/aboutguest 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 10 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-10-17