PHPackages                             browscap/browscap - 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. browscap/browscap

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

browscap/browscap
=================

Browser Capabilities Tools

6028(8y ago)446115.0k731MITPHPPHP ^7.1CI passing

Since Jan 22Pushed 2mo ago35 watchersCompare

[ Source](https://github.com/browscap/browscap)[ Packagist](https://packagist.org/packages/browscap/browscap)[ Docs](https://github.com/browscap/browscap)[ RSS](/packages/browscap-browscap/feed)WikiDiscussions 6.1.x Synced 1mo ago

READMEChangelog (10)Dependencies (9)Versions (85)Used By (1)

Browser Capabilities Project
============================

[](#browser-capabilities-project)

[![Continuous Integration](https://github.com/browscap/browscap/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/browscap/browscap/actions/workflows/continuous-integration.yml)[![codecov](https://camo.githubusercontent.com/a524663a5c1d5765d31339bb12fec5bdce2fb7ff01dbad98c61b1c3241204d68/68747470733a2f2f636f6465636f762e696f2f67682f62726f77736361702f62726f77736361702f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/browscap/browscap)

This tool is used to build and maintain browscap files.

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

[](#installation)

```
$ git clone git://github.com/browscap/browscap.git
$ cd browscap
$ curl -s https://getcomposer.org/installer | php
$ php composer.phar install

```

What's changed in version 6048
------------------------------

[](#whats-changed-in-version-6048)

- [\#2535](https://github.com/browscap/browscap/pull/2535) Added recent new Apple platforms (Mac OS, iOS and iPadOS)

What's changed in version 6028
------------------------------

[](#whats-changed-in-version-6028)

### BC breaks listed

[](#bc-breaks-listed)

- Interface changed for class \\Browscap\\Data\\Factory\\UserAgentFactory

What's changed in version 6027
------------------------------

[](#whats-changed-in-version-6027)

### BC breaks listed

[](#bc-breaks-listed-1)

- Strict type hints have been added throughout. This may break some type assumptions made in earlier versions.
- In many classes Setters and Getters have been removed, the parameters have been moved to the class constructor
- Some classes are now `final` - use composition instead of inheritance

What's changed in version 6025
------------------------------

[](#whats-changed-in-version-6025)

### BC breaks listed

[](#bc-breaks-listed-2)

- The `grep` command and the `diff` command were removed

### Changes

[](#changes)

- The tests for integration testing the source files are split from the other tests
- Tests on travis use the build pipeline now

Directory Structure
-------------------

[](#directory-structure)

- `bin` - Contains executable files
- `build` - Contains various builds
- `resources` - Files needed to build the various files, also used to validate the capabilities
- `src` - The code of this project lives here
- `tests` - The testing code of this project lives here

the CLI commands
----------------

[](#the-cli-commands)

There is actually only one cli command available.

### build

[](#build)

This command is used to build a set of defined browscap files.

```
bin/browscap build [version]
```

#### options

[](#options)

- `version` (required) the name of the version that should be built
- `output` (optional) the directory where the files should be created
- `resources` (optional) the directory where the sources for the build are located
- `coverage` (optional) if this option is set, during the build information is added which can be used to generate a coverage report
- `no-zip` (optional) if this option is set, no zip file is generated during the build

For further documentation on the `build` command, [see here](https://github.com/browscap/browscap/wiki/Build-Command).

CLI Examples
------------

[](#cli-examples)

You can export a new set of browscap files:

```
$ bin/browscap build 5020-test
Resource folder:
Build folder:
Generating full_asp_browscap.ini [ASP/FULL]
Generating full_php_browscap.ini [PHP/FULL]
Generating browscap.ini [ASP]
Generating php_browscap.ini [PHP]
...
All done.
$

```

Now you if you look at `browscap/browscap.ini` you will see a new INI file has been generated.

Usage Examples
--------------

[](#usage-examples)

### How to build a standard set of browscap files

[](#how-to-build-a-standard-set-of-browscap-files)

This example assumes that you want to build all \*php\_browscap.ini files.

```
$logger = new \Monolog\Logger('browscap'); // or maybe any other PSR-3 compatible Logger

$format = \Browscap\Formatter\FormatterInterface::TYPE_PHP; // you may choose the output format you want, the format must be already supported

$resourceFolder = 'resources/'; // please point to the resources directory inside the project
$buildFolder = ''; // choose the directory where the generated file should be written to

// If you are using one of the predefined WriterFactories, you may not choose the file names
$writerCollection = (new \Browscap\Writer\Factory\PhpWriterFactory())->createCollection($logger, $buildFolder);

$dataCollectionFactory = new \Browscap\Data\Factory\DataCollectionFactory($logger);

$buildGenerator = new BuildGenerator(
    $resourceFolder,
    $buildFolder,
    $logger,
    $writerCollection,
    $dataCollectionFactory
);

$version       = '';    // what you want to be written into the generated file
$createZipFile = false; // It is not possible yet to create a zipped version of a custom named browscap file

$buildGenerator->run($version, $createZipFile);
```

### How to build a custom set of browscap files

[](#how-to-build-a-custom-set-of-browscap-files)

If you want to build a custom set of browscap files, you may not use the predefined WriterFactories.

```
$logger = new \Monolog\Logger('browscap'); // or maybe any other PSR-3 compatible Logger

$format = \Browscap\Formatter\FormatterInterface::TYPE_PHP; // you may choose the output format you want, the format must be already supported

$resourceFolder = 'resources/'; // please point to the resources directory inside the project
$buildFolder = ''; // choose the directory where the generated file should be written to

$propertyHolder = new \Browscap\Data\PropertyHolder();

// build a standard version browscap.json file
$jsonFormatter = new \Browscap\Formatter\JsonFormatter($propertyHolder);
$jsonFilter    = new \Browscap\Filter\StandardFilter($propertyHolder);

$jsonWriter = new \Browscap\Writer\JsonWriter('relative path or name of the target file', $logger);
$jsonWriter->setFormatter($jsonFormatter);
$jsonWriter->setFilter($jsonFilter);

// build a lite version browscap.xml file
$xmlFormatter = new \Browscap\Formatter\XmlFormatter($propertyHolder);
$xmlFilter    = new \Browscap\Filter\LiteFilter($propertyHolder);

$xmlWriter = new \Browscap\Writer\XmlWriter('relative path or name of the target file', $logger);
$xmlWriter->setFormatter($xmlFormatter);
$xmlWriter->setFilter($xmlFilter);

$writerCollection = new \Browscap\Writer\WriterCollection();
$writerCollection->addWriter($jsonWriter);
$writerCollection->addWriter($xmlWriter);

$dataCollectionFactory = new \Browscap\Data\Factory\DataCollectionFactory($logger);

$buildGenerator = new BuildGenerator(
    $resourceFolder,
    $buildFolder,
    $logger,
    $writerCollection,
    $dataCollectionFactory
);

$version       = '';    // what you want to be written into the generated file
$createZipFile = false; // It is not possible yet to create a zipped version of a custom named browscap file

$buildGenerator->run($version, $createZipFile);
```

### How to build a custom browscap.ini

[](#how-to-build-a-custom-browscapini)

If you want to build a custom browscap file you may choose the file name and the fields which are included.

Note: It is not possible to build a custom browscap.ini file with the CLI command.

```
$logger = new \Monolog\Logger('browscap'); // or maybe any other PSR-3 compatible Logger
// If using Monolog, you need specify a log handler, e.g. for STDOUT: $logger->pushHandler(new \Monolog\Handler\ErrorLogHandler());

$format = \Browscap\Formatter\FormatterInterface::TYPE_PHP; // you may choose the output format you want, the format must be already supported
$file   = null; // you may set a custom file name here
$fields = []; // choose the fields you want inside of your browscap file

$resourceFolder = 'resources/'; // please point to the resources directory inside the project
$buildFolder = ''; // choose the directory where the generated file should be written to

$writerCollection = (new \Browscap\Writer\Factory\CustomWriterFactory())->createCollection($logger, $buildFolder, $file, $fields, $format);

$dataCollectionFactory = new \Browscap\Data\Factory\DataCollectionFactory($logger);

$buildGenerator = new BuildGenerator(
    $resourceFolder,
    $buildFolder,
    $logger,
    $writerCollection,
    $dataCollectionFactory
);

$version       = ''; // version you want to be written into the generated file
$dateTime      = new \DateTimeImmutable(); // date you want to be written into the generated file
$createZipFile = false; // It is not possible yet to create a zipped version of a custom named browscap file

$buildGenerator->run($version, $dateTime, $createZipFile);
```

Issues and feature requests
---------------------------

[](#issues-and-feature-requests)

Please report your issues and ask for new features on the GitHub Issue Tracker at

### Contributing

[](#contributing)

For instructions on how to contribute see the [CONTRIBUTE.md](https://github.com/browscap/browscap/blob/master/CONTRIBUTING.md) file.

### License

[](#license)

See the [LICENSE](https://github.com/browscap/browscap/blob/master/LICENSE) file.

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance58

Moderate activity, may be stable

Popularity49

Moderate usage in the ecosystem

Community38

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 65.6% 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 ~54 days

Recently: every ~244 days

Total

82

Last Release

52d ago

PHP version history (10 changes)5021PHP &gt;= 5.4.0

6003PHP &gt;= 5.5.0

6013PHP &gt;= 5.6.0

6019PHP ^7.0 | ^7.1

6022PHP ^7.0

6025PHP ^7.1

6.0.39PHP ^7.1.3

6.1.0PHP &gt;=8.1.0,&lt;8.2.0

6.1.3PHP &gt;=8.1.0,&lt;8.3.0

6.1.7PHP &gt;=8.1.0,&lt;8.4.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/447419?v=4)[Joshua Estes](/maintainers/joshuaestes)[@JoshuaEstes](https://github.com/JoshuaEstes)

![](https://www.gravatar.com/avatar/2734194006e4987a8e12379a63b4f6c0a4478b5818ea7ce677499b1f714a92d2?d=identicon)[asgrim](/maintainers/asgrim)

![](https://www.gravatar.com/avatar/5fea77dd303122241a6caac15ea7456607bcb6f5db869fc8fc9eaf3ec0630a84?d=identicon)[mimmi20](/maintainers/mimmi20)

![](https://avatars.githubusercontent.com/u/136907?v=4)[Jay Klehr](/maintainers/jaydiablo)[@jaydiablo](https://github.com/jaydiablo)

---

Top Contributors

[![mimmi20](https://avatars.githubusercontent.com/u/1120192?v=4)](https://github.com/mimmi20 "mimmi20 (4892 commits)")[![asgrim](https://avatars.githubusercontent.com/u/496145?v=4)](https://github.com/asgrim "asgrim (1365 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (570 commits)")[![jaydiablo](https://avatars.githubusercontent.com/u/136907?v=4)](https://github.com/jaydiablo "jaydiablo (391 commits)")[![paulrutter](https://avatars.githubusercontent.com/u/11535991?v=4)](https://github.com/paulrutter "paulrutter (66 commits)")[![willyaranda](https://avatars.githubusercontent.com/u/679157?v=4)](https://github.com/willyaranda "willyaranda (25 commits)")[![mmorel-35](https://avatars.githubusercontent.com/u/6032561?v=4)](https://github.com/mmorel-35 "mmorel-35 (25 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (25 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (19 commits)")[![JoshuaEstes](https://avatars.githubusercontent.com/u/447419?v=4)](https://github.com/JoshuaEstes "JoshuaEstes (11 commits)")[![vermorag](https://avatars.githubusercontent.com/u/25276845?v=4)](https://github.com/vermorag "vermorag (9 commits)")[![koenr-bc](https://avatars.githubusercontent.com/u/81305134?v=4)](https://github.com/koenr-bc "koenr-bc (9 commits)")[![allie](https://avatars.githubusercontent.com/u/10043207?v=4)](https://github.com/allie "allie (8 commits)")[![prox2k](https://avatars.githubusercontent.com/u/7900311?v=4)](https://github.com/prox2k "prox2k (7 commits)")[![aumel](https://avatars.githubusercontent.com/u/8963945?v=4)](https://github.com/aumel "aumel (7 commits)")[![chappy84](https://avatars.githubusercontent.com/u/912440?v=4)](https://github.com/chappy84 "chappy84 (6 commits)")[![ocluf](https://avatars.githubusercontent.com/u/74682764?v=4)](https://github.com/ocluf "ocluf (5 commits)")[![abuchmann-ga](https://avatars.githubusercontent.com/u/106234339?v=4)](https://github.com/abuchmann-ga "abuchmann-ga (4 commits)")[![mikhainin](https://avatars.githubusercontent.com/u/195510?v=4)](https://github.com/mikhainin "mikhainin (4 commits)")[![Xathz](https://avatars.githubusercontent.com/u/13627748?v=4)](https://github.com/Xathz "Xathz (3 commits)")

---

Tags

detectphpua-parseruser-agentuser-agent-parserBrowscap

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/browscap-browscap/health.svg)

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

###  Alternatives

[vaimo/composer-patches

Applies a patch from a local or remote file to any package that is part of a given composer project. Patches can be defined both on project and on package level. Optional support for patch versioning, sequencing, custom patch applier configuration and patch command for testing/troubleshooting added patches.

2994.3M16](/packages/vaimo-composer-patches)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[php-soap/wsdl

Deals with WSDLs

173.5M12](/packages/php-soap-wsdl)[vaimo/composer-changelogs

Provide information about package changes based on changelog files that are bundled with releases; provide tools for generating documentation files from changelog sources

11150.5k10](/packages/vaimo-composer-changelogs)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[propa/laravel-browscap

Browscap-PHP integration for Laravel 5-12

1060.3k](/packages/propa-laravel-browscap)

PHPackages © 2026

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