PHPackages                             phile/user-agent - 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. phile/user-agent

ActivePhile-plugin[Utility &amp; Helpers](/categories/utility)

phile/user-agent
================

A plugin for Phile to expose browser user-agent data to the template.

0132PHP

Since Jun 19Pushed 11y ago2 watchersCompare

[ Source](https://github.com/PhileCMS/phileUserAgent)[ Packagist](https://packagist.org/packages/phile/user-agent)[ RSS](/packages/phile-user-agent/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (1)DependenciesVersions (1)Used By (0)

phileUserAgent
==============

[](#phileuseragent)

A plugin for [Phile](https://github.com/PhileCMS/Phile) to expose browser user-agent data to the template.

### 1.1 Installation (composer)

[](#11-installation-composer)

```
php composer.phar require phile/user-agent:*

```

### 1.2 Installation (Download)

[](#12-installation-download)

- Install the latest version of [Phile](https://github.com/PhileCMS/Phile)
- Clone this repo into `plugins/phile/userAgent`

### 2. Activation

[](#2-activation)

After you have installed the plugin. You need to add the following line to your `config.php` file:

```
$config['plugins']['phile\\userAgent'] = array('active' => true);

```

### Usage

[](#usage)

This plugin will create a new variable in your template called `{{ useragent }}`.

You can use this varaible to load conditional content, add special classes, or even modify your javascript.

#### Exposed Infomation

[](#exposed-infomation)

Here is an example (from my laptop) of the full useragent array:

```
array(
  'useragent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.6 Safari/537.36', // full useragent string
  'name' => 'Google Chrome', // name of the browser
  'browser' => 'google-chrome', // css safe browser name
  'version' => '32.0.1700.6', // browser version number
  'type' => 'desktop', // form factor browser || mobile
  'platform' => 'mac', // Operating System
  'pattern' => '#(?Version|Chrome|other)[/ ]+(?[0-9.|a-zA-Z.]*)#' // regex pattern that matched
);
```

#### Conditional Content

[](#conditional-content)

```
{% if useragent.type == 'desktop' %}

{% else %}

{% endif %}
```

#### Special Classes

[](#special-classes)

```

    {{ content }}

```

#### Javascript Additions

[](#javascript-additions)

If we put this code in the *head of our document*, we can encode the `{{ useragent }}` array as json and use it in our javascript:

```

  window.Phile.useragent = {{ useragent|json_encode() }};

```

Now `Phile.useragent.browser` would return the CSS safe browser name in our javascript.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/e96d91f6220abcbbf2e6bcd12988b11330178e08a33cd663e813257a359b12fc?d=identicon)[NeoBlack](/maintainers/NeoBlack)

---

Top Contributors

[![james2doyle](https://avatars.githubusercontent.com/u/1425304?v=4)](https://github.com/james2doyle "james2doyle (12 commits)")[![drummerdude545](https://avatars.githubusercontent.com/u/4081095?v=4)](https://github.com/drummerdude545 "drummerdude545 (2 commits)")[![NeoBlack](https://avatars.githubusercontent.com/u/1128085?v=4)](https://github.com/NeoBlack "NeoBlack (2 commits)")

---

Tags

philecms-plugin

### Embed Badge

![Health badge](/badges/phile-user-agent/health.svg)

```
[![Health](https://phpackages.com/badges/phile-user-agent/health.svg)](https://phpackages.com/packages/phile-user-agent)
```

###  Alternatives

[dillingham/nova-attach-many

Attach Many Nova field

2712.0M2](/packages/dillingham-nova-attach-many)[primal/color

Collection of classes for converting and manipulating colors

24506.7k5](/packages/primal-color)[faryshta/yii2-enum

Enum classes for Yii2 models and forms

15332.9k](/packages/faryshta-yii2-enum)[acsiomatic/device-detector-bundle

Symfony Bundle for https://github.com/matomo-org/device-detector

12183.6k](/packages/acsiomatic-device-detector-bundle)[braunson/laravel-html5-forms

This package extends Laravel's FormBuilder to include some (soon all) HTML5 elements

851.1k](/packages/braunson-laravel-html5-forms)

PHPackages © 2026

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