Jenssegers Agent

PHP desktop and mobile user-agent parser with first-class Laravel support.

Library
Composer
vv2.6.4
4,839stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
48/100Fair
Development Activity0
Maintenance20
Community72
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
77/100Good
Architecture76
Code Quality78
Innovation68
Learning Curve88

Jenssegers Agent is a PHP user-agent parser that detects browsers, platforms, devices, and robots from HTTP request headers. Built on top of Mobile Detect with added desktop support, it exposes a friendly, expressive API for inspecting who and what is visiting your application.

It ships with optional Laravel integration via a service provider and facade, so you can resolve an Agent instance for the current request out of the box. Whether you need to branch UI for mobile visitors, gather analytics on browser share, or filter crawlers, Agent turns raw user-agent strings into readable, queryable information.

What You Get

  • A single Agent class that parses browser, platform, device, and robot from user-agent headers
  • Magic is-methods such as isMobile(), isTablet(), isDesktop(), and isRobot()
  • Optional Laravel service provider and Agent facade for zero-config request parsing
  • Accept-language extraction and browser/platform version detection
  • Robot detection powered by jaybizzle/crawler-detect

Common Use Cases

  • Serving different layouts or assets to mobile versus desktop visitors
  • Collecting browser and platform breakdowns for analytics
  • Filtering or logging bot and crawler traffic
  • Reading a visitor’s preferred languages for localization

Under The Hood

Architecture - The library is small and focused: src/Agent.php extends Mobile Detect’s detection engine and layers on desktop, browser, platform, and robot rule sets, plus accept-language parsing. src/AgentServiceProvider.php registers a request-scoped Agent binding for Laravel, and src/Facades exposes the Agent facade. Magic is-methods are dispatched through __call to match rule names dynamically.

Tech Stack - Pure PHP (>=5.6) with three runtime dependencies: mobiledetect/mobiledetectlib for the core signature matching, jaybizzle/crawler-detect for robot detection, and optionally illuminate/support for the Laravel integration. Autoloading is PSR-4 under the Jenssegers\Agent namespace; the Laravel provider and alias are declared via composer extra metadata.

Code Quality - The tests directory contains AgentTest, BasicTest, UserAgentTest, and VendorsTest suites exercised with PHPUnit, including checks against real vendor user-agent fixtures. The codebase is compact and readable, though it targets older PHP versions and has been in maintenance mode.

API Design - The API is intentionally minimal and expressive: instantiate Agent, optionally setUserAgent()/setHttpHeaders(), then call browser(), platform(), device(), languages(), or any isX() magic method. The Laravel facade removes boilerplate entirely, making common detection a one-liner.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search