承接 spinzar/laravel-agent 相关项目开发

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

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

spinzar/laravel-agent

Composer 安装命令:

composer require spinzar/laravel-agent

包简介

Desktop/mobile user agent parser with support for Laravel, based on MobileDetect

README 文档

README

The [Agent] package seems to be incompatible with Laravel 11. Let's move forward with a different approach to achieve the desired functionality.

Warning: This package is for [demonstration purposes / personal learning only]. Use at your own risk! It may have bugs or functionalities not suitable for production.

In Laravel versions below 11, you'll need to use Agent recommended.

Laravel Agent acts as a bridge between your Laravel application and the user's device,

allowing you to make informed decisions about how to present your content and interact with your users

based on the device they're using. This results in a more tailored and user-friendly experience for everyone.

Focusing on Functionality:

  • "Another package relies on the features provided by package-name above. We need to ensure it's included as a dependency."

Installation

Install using composer:

composer require spinzar/laravel-agent

Laravel (optional)

Add the service provider in config/app.php:

Spinzar\LaravelAgent\AgentServiceProvider::class,

And add the LaravelAgent alias to config/app.php:

'LaravelAgent' => Spinzar\LaravelAgent\Facades\LaravelAgent::class,

Basic Usage

Start by creating an LaravelAgent instance (or use the LaravelAgent Facade if you are using Laravel):

use Spinzar\LaravelAgent\LaravelAgent;

$larvaelagent = new LaravelAgent();

If you want to parse user agents other than the current request in CLI scripts for example, you can use the setUserAgent and setHttpHeaders methods:

$larvaelagent->setUserAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2');
$larvaelagent->setHttpHeaders($headers);

Is?

Check for a certain property in the user agent.

$larvaelagent->is('Windows');
$larvaelagent->is('Firefox');
$larvaelagent->is('iPhone');
$larvaelagent->is('iPad');
$larvaelagent->is('OS X');

Magic is-method

Magic method that does the same as the previous is() method:

$larvaelagent->isAndroidOS();
$larvaelagent->isNexus();
$larvaelagent->isSafari();

Mobile detection

Check for mobile device:

$larvaelagent->isMobile();
$larvaelagent->isTablet();

Match user agent

Search the user agent with a regular expression:

$larvaelagent->match('regexp');

Additional Functionality

Accept languages

Get the browser's accept languages. Example:

$languages = $larvaelagent->languages();
// ['nl-nl', 'nl', 'en-us', 'en']

Device name

Get the device name, if mobile. (iPhone, Nexus, AsusTablet, ...)

$device = $larvaelagent->device();

Operating system name

Get the operating system. (Ubuntu, Windows, OS X, ...)

$platform = $larvaelagent->platform();

Browser name

Get the browser name. (Chrome, IE, Safari, Firefox, ...)

$browser = $larvaelagent->browser();

Desktop detection

Check if the user is using a desktop device.

$larvaelagent->isDesktop();

This checks if a user is not a mobile device, tablet or robot.

Phone detection

Check if the user is using a phone device.

$larvaelagent->isPhone();

Robot detection

Check if the user is a robot. This uses jaybizzle/crawler-detect to do the actual robot detection.

$larvaelagent->isRobot();

Robot name

Get the robot name.

$robot = $larvaelagent->robot();

Browser/platform version

MobileDetect recently added a version method that can get the version number for components. To get the browser or platform version you can use:

$browser = $larvaelagent->browser();
$version = $larvaelagent->version($browser);

$platform = $larvaelagent->platform();
$version = $larvaelagent->version($platform);

Note, the version method is still in beta, so it might not return the correct result.

License

Laravel User Agent is licensed under The MIT License (MIT).

spinzar/laravel-agent 适用场景与选型建议

spinzar/laravel-agent 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 06 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 spinzar/laravel-agent 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-06-02