Jenssegers Agent
PHP desktop and mobile user-agent parser with first-class Laravel support.
Repository Health
Technical Analysis
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.
Used by 2 apps in this directory
Pixelfed
Social Media
A decentralized, self-hosted photo sharing platform built on ActivityPub for the open Fediverse.
Vanguard Backup
Devops
Self-hosted backup automation for Ubuntu and Debian servers with S3 storage, SSH-based file and database backup, and multi-channel notifications.