Try Depot: Bring ultra-fast, remote Docker builds directly to your Laravel workflow

Browser Detect

hisorange/browser-detect image

Browser Detect stats

Downloads
4.4M
Stars
961
Open Issues
1
Forks
137

View on GitHub →

Browser & Mobile detection package for Laravel.

Browser Detection v5.0 by hisorange

Browser Detection is a robust Laravel package designed to effortlessly determine the browser details and device type of website visitors. Developed by hisorange, this package leverages well-tested underlying libraries to provide accurate detection without relying on "magic."

Key Features:

  • Comprehensive Browser Insights: Detects browser type, version, engine, and whether the visitor is using a mobile, tablet, or desktop device.
  • Device and OS Detection: Identifies the device model, family, and operating system, including specifics like version numbers and major families (e.g., Windows, Linux, iOS).
  • Bot Detection: Easily check if a visitor is a bot, which can be useful for analytics and custom content delivery.
  • Extended Compatibility: Supports Laravel versions from 4.0 to 10.x and PHP versions from 5.6 to 8.2.
  • Standalone Usage: Can be used outside of Laravel projects by utilizing the Parser class directly.
  • Blade Directive Support: Includes custom directives for Blade templates, enabling conditional rendering based on device type.

Installation

Install via composer:

composer require hisorange/browser-detect

Usage Examples

In PHP code:

use Browser;
 
if (Browser::isMobile()) {
// Specific actions for mobile devices
}
 
// Detect if the user's browser is Firefox or Opera
if (Browser::isFirefox() || Browser::isOpera()) {
echo '<script src="firefox-fix.js"></script>';
}
 
// Blade template directives
@mobile
<p>Mobile content here</p>
@endmobile

Configuration

For Laravel users, publish the configuration file with:

php artisan vendor:publish

For standalone mode, customize configuration when creating a Parser instance:

$browser = new Parser(null, null, ['cache' => ['interval' => 86400]]);

Advanced Usage

Parse custom user-agent strings or access detailed browser properties:

$result = Browser::parse('Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14');

Summary

hisorange's Browser Detection is an efficient and flexible solution for Laravel and non-Laravel PHP applications to gather detailed browser and device information, enhancing user experience and system analytics. With out-of-the-box support for multiple environments and minimal configuration, it's a valuable tool for developers looking to streamline visitor analysis.

hisorange photo

WebArtisan since ~2003


Hisorange Browser Detect Related Articles

Laravel Boost, your AI coding starter kit image

Laravel Boost, your AI coding starter kit

Read article
Everything We Know About Pest 4 image

Everything We Know About Pest 4

Read article
PhpStorm 2025.1 is Here image

PhpStorm 2025.1 is Here

Read article
Tailwind CSS v4 is Here image

Tailwind CSS v4 is Here

Read article
Herd 1.4.0 is now out with a pro version and Windows in the works image

Herd 1.4.0 is now out with a pro version and Windows in the works

Read article
LangCountry is a Localization Package for Laravel image

LangCountry is a Localization Package for Laravel

Read article
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud