Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Phpuseragentparser Laravel Package

donatj/phpuseragentparser

Lightweight PHP user-agent parser for detecting modern browsers and platforms from UA strings. Tiny codebase (<200 lines, 3 regexes), fast and accurate (including tricky IE versions). Composer-ready, 100% unit-tested, with optional object wrapper.

View on GitHub
Deep Wiki
Context7
v1.12.0

Adds / Improves support for bots.

Formal support for many many bots including Claude and Perplexity among many others.

Adds a new Bots helper class you can use for identifying specific bots.

What's Changed

New Contributors

Full Changelog: https://github.com/donatj/PhpUserAgent/compare/v1.11.0...v1.12.0

v1.9.0

What's Changed

Full Changelog: https://github.com/donatj/PhpUserAgent/compare/v1.8.0...v1.9.0

v0.23.0

DEPRECATED RELEASE - PLEASE UPGRADE TO 1.8.0 for EXACT PARITY

See 1.8.0 for changelog

Full Changelog: https://github.com/donatj/PhpUserAgent/compare/v0.22.0...v0.23.0

v1.8.0

What's Changed

  • Adds a lot of test coverage
  • Officially support Slackbot
  • Better bot support overall

Full Changelog: https://github.com/donatj/PhpUserAgent/compare/v1.7.0...v1.8.0

v0.22.0

DEPRECATED RELEASE - PLEASE UPGRADE TO 1.7.0 for EXACT PARITY

v1.7.0
  • Fix deprecation notice on PHP 8.1 #86 - Thanks @kocsismate
  • Fix AndroidBrowser detection on old versions of Android

Full Changelog: https://github.com/donatj/PhpUserAgent/compare/v1.6.1...v1.7.0

v1.6.1
v1.6.0

What's Changed

New Contributors

Full Changelog: https://github.com/donatj/PhpUserAgent/compare/v1.5.0...v1.6.0

v1.5.0
  • Adds PlayStation 5 support
  • Drops Support for PHP 5.3
  • General cleanup
  • Improved Firefox test coverage
v0.20.0

Adds official support for TelegramBot and Twitterbot.

They were already detected but did not have tests.

Adds sniffing and support for iMessageBot.

Please upgrade to the 1.x release.

This is a deprecated release for compatibility.

The functionality of this release is mirrored exactly by v1.3.0 and does not break compatibility. You can easily upgrade.

The 0.x releases will soon no longer be maintained.

Please upgrade ASAP.

v1.4.0

Adds official support for TelegramBot and Twitterbot.

They were already detected but did not have constants nor tests.

Adds sniffing and support for iMessageBot.

v0.19.0

Adds:

  • Support for Miui Browser
  • Support for Sailfish OS
  • Support for Sailfish Browser

Please consider upgrading to the 1.x release.

This is a deprecated release for compatibility.

The functionality of this release is mirrored exactly by v1.3.0 and does not break compatibility. The 0.x releases will soon no longer be maintained. Please upgrade ASAP.

v1.3.0

Adds:

  • Support for Miui Browser
  • Support for Sailfish OS
  • Support for Sailfish Browser
v1.2.0
  • Older versions of UC Browser noted the platform as Adr rather than Android - handle this weirdness.
  • Add a bunch of tests for UC Browser
v0.18.0
  • Older versions of UC Browser noted the platform as Adr rather than Android - handle this weirdness.
  • Add a bunch of tests for UC Browser

Please consider upgrading to the 1.x release.

This is a deprecated release for compatibility.

The functionality of this release is mirrored exactly by v1.2.0 and does not break compatibility. The 0.x releases will soon no longer be maintained. Please upgrade ASAP.

v0.17.0

Adds support for the Applebot - http://www.apple.com/go/applebot

Please consider upgrading to the 1.x release.

The functionality of this release is mirrored by v1.1.0 and does not break backwards compatibility. The 0.x releases will soon no longer be maintained.

v1.1.0

Adds support for the Applebot - http://www.apple.com/go/applebot

v1.0.0

This is a major rework of the entire project that took just under 2 years. The utmost care went into considering how to keep this both the small and light library the community enjoys, but also add features people have been clamoring for since the beginning. I really believe we've hit the nail on the head here.

Backwards Compatibility Considerations:

A lot of work went into not breaking compatibility especially for people not using composer. If you encounter any issues with compatibility let us know and we will fix it ASAP.

All required "functional" logic remains in a single file src/UserAgentParser.php This is specifically to make the library easy to use for people who do not use composer.

Adds:

  • Object oriented convenience wrapper ecosystem.
    • \donatj\UserAgent\UserAgentParser - Object oriented parse_user_agent call wrapper.
    • \donatj\UserAgent\UserAgent - Object oriented response object.
    • \donatj\UserAgent\UserAgentInterface - Helper interface for test mocking.
  • Namespaced \donatj\UserAgent\parse_user_agent function to mirror global parse_user_agent
  • Constants for the returned arrays keys
    • \donatj\UserAgent\PLATFORM = 'platform';
    • \donatj\UserAgent\BROWSER = 'browser';
    • \donatj\UserAgent\BROWSER_VERSION = 'version';
  • Helpful predefined constants to check against for Platforms and Browsers generated from the same dataset as the tests.
    • \donatj\UserAgent\Browsers::*
    • \donatj\UserAgent\Platforms::*
  • Even more test cases

Changes:

  • parse_user_agent is deprecated in favor of \donatj\UserAgent\parse_user_agent
    • Will remain in the code until at least 2.x

Thus require "{$dir}/src/UserAgentParser.php"; remains a supported method of using the library.

Upgrading to 1.*

The new 1.* release does not break compatibility with 0.* and nothing need to change to upgrade. However, the global parse_user_agent is now deprecated; it has been replaced with the namespaced \donatj\UserAgent\parse_user_agent and functions exactly the same. You can easily replace any existing call to parse_user_agent with \donatj\UserAgent\parse_user_agent

In addition, 1.x adds a convenience object wrapper you may use should you prefer. More information on this is in the Usage section of the README.


I would also like to personally thank @mimmi20 for helping review ideas early in the project's life cycle.

v0.16.0

Fixes:

  • Corrects an issue detecting with newer versions of UC Browser. See: #63

Updates:

  • Refactored the code into a smaller number of test cases. Seems to actually be a very slight performance boon.
v0.15.0

Drops support for Opera Next - it's not really a thing anymore and supporting it was interfering with proper detection of Opera propper.

v0.14.0

Adds basic support for Microsoft's new Blink based Edge browser. Slight improvements to PS4 support.

v0.13.0

Performance Improvements!

I made a number of seemingly minor changes to the regular expressions that when benchmarked resulted in a nearly 3% performance improvement.

Reorganized directory structure to be more standard

Old Path New Path
Source/ src/
Tools/ bin/
Tests/ test/

Warning: if you are directly requiring the PHP file rather than using composer this will be a breaking change.

v0.12.0

Adds basic support and tests for OculusBrowser

v0.11.1

Adds support for Yandex.


v0.11.0 was deleted.

A cherry pick from an upstream branch went awry as it made use of a constant not currently defined.

This hotfix removes said constant.

v0.10.0

Now differentiates between HeadlessChrome and Chrome.

v0.9.0

Adds Nintendo Switch browser support.

v0.8.0

It was pointed out that a number of BSD based OS's showed up as "Linux" which isn't accurate/correct.

This has been corrected with the help of @goshoo

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky