Package

Hisorange Browser Detect

Browser & Mobile detection package for Laravel.

Package

hisorange/browser-detect

View on GitHub →

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 Browser Detect Related Articles

Laravel Dusk Browser Testing: Best Practices & Tips image

Laravel Dusk Browser Testing: Best Practices & Tips

Read article
Detect and Change Indentation With PHP image

Detect and Change Indentation With PHP

Read article
Laravel Dusk & GitHub Actions: Running Dusk in CI Pipelines image

Laravel Dusk & GitHub Actions: Running Dusk in CI Pipelines

Read article
How to Detect n+1 Queries in PHP image

How to Detect n+1 Queries in PHP

Read article
Manage a User's Browser Sessions in Laravel image

Manage a User's Browser Sessions in Laravel

Read article
JSON Alexander Gives Developers a Simpler, More Trustworthy Way to View JSON in the Browser image

JSON Alexander Gives Developers a Simpler, More Trustworthy Way to View JSON in the Browser

Read article

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm

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

Let your users buy domains without leaving your app

If your Laravel app gives users a site, a storefront, or a workspace, they’ll eventually want their own domain. The name.com API lets them search, register, and connect one without leaving your product. It’s a clean REST API, so Laravel’s HTTP client is all you need.

Let your users buy domains without leaving your app

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum