PHPackages                             dartui/browser-language - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. dartui/browser-language

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

dartui/browser-language
=======================

1.0.1(1y ago)170.5k—6.3%1MITPHPPHP ^7.3|^8.0

Since Apr 16Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Dartui/browser-language)[ Packagist](https://packagist.org/packages/dartui/browser-language)[ RSS](/packages/dartui-browser-language/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

Browser Language
================

[](#browser-language)

Detect languages supported by user browser in PHP.

How it works?
-------------

[](#how-it-works)

While requesting for data, browsers are sending `Accept-Language` header to server. It contains information about which language user can understand. We can use this value to serve content for users with their preferred language automatically.

Unfortunately, `Accept-Language` header is a bit complicated and needs parsing. That is the reason why you may need this package.

Installation
------------

[](#installation)

Use composer to install package in your project.

```
composer require dartui/browser-language
```

Usage
-----

[](#usage)

```
use Dartui\BrowserLanguage\BrowserLanguage;

/**
 * Constructor tries to get Accept-Language value from $_SERVER superglobal.
 */
$browserLanguage = new BrowserLanguage();

/**
 * Additionally you can pass Accept-Language header value
 * or hardcoded value by yourself.
 */
$browserLanguage = new BrowserLanguage('en-US,en;q=0.5,pl;q=0.3');

/**
 * Get the list of all supported languages sorted by factor.
 * Example: [en-US, en, pl]
 */
$allLanguages = $browserLanguage->all();

/**
 * Get the best match for user browser language.
 * Example: en-US
 */
$language = $browserLanguage->best();
```

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1199 days

Total

2

Last Release

659d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/95dd08b3f7f83eedb53d6a13b37a9c2121336d1ae1615e79d5b274e59d32ead8?d=identicon)[Dartui](/maintainers/Dartui)

---

Top Contributors

[![Dartui](https://avatars.githubusercontent.com/u/2657856?v=4)](https://github.com/Dartui "Dartui (6 commits)")[![kryswoj](https://avatars.githubusercontent.com/u/70862071?v=4)](https://github.com/kryswoj "kryswoj (1 commits)")[![stevedecoded](https://avatars.githubusercontent.com/u/673850?v=4)](https://github.com/stevedecoded "stevedecoded (1 commits)")

---

Tags

browserheaderlanguagephp

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dartui-browser-language/health.svg)

```
[![Health](https://phpackages.com/badges/dartui-browser-language/health.svg)](https://phpackages.com/packages/dartui-browser-language)
```

###  Alternatives

[mad-web/laravel-enum

Elegant Enum implementation for Laravel. With make:enum command, ability to casting for Eloquent models and labels translations via lang files.

110136.0k](/packages/mad-web-laravel-enum)[mad-web/nova-horizon-link

Smart Link for Laravel Nova to Horizon Dashboard.

24201.4k](/packages/mad-web-nova-horizon-link)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
