Skip to content

Commit

Permalink
Update README + CHANGELOG
Browse files Browse the repository at this point in the history
  • Loading branch information
GeLoLabs committed Jul 9, 2013
1 parent e64da6d commit 9c6ae12
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 32 deletions.
3 changes: 0 additions & 3 deletions CHANGELOG

This file was deleted.

9 changes: 9 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,9 @@
# CHANGELOG

### 1.0.0 (2013-08-09)

* Add a version following semver spec.

### v1.0 - 2010-04-13

* create initial 1.0 version
69 changes: 40 additions & 29 deletions README.markdown → README.md
Expand Up @@ -5,12 +5,14 @@ Uses a simple and fast algorithm to recognize major browsers.

## Overview

$userAgent = new phpUserAgent();
``` php
$userAgent = new phpUserAgent();

$userAgent->getBrowserName() // firefox
$userAgent->getBrowserVersion() // 3.6
$userAgent->getOperatingSystem() // linux
$userAgent->getEngine() // gecko
$userAgent->getBrowserName() // firefox
$userAgent->getBrowserVersion() // 3.6
$userAgent->getOperatingSystem() // linux
$userAgent->getEngine() // gecko
```

### Why you should use it

Expand All @@ -26,17 +28,20 @@ It is performant as well, since it doesn't do any iteration or recursion.

## Usage

// include the class
require_once '/path/to/php-user-agent/phpUserAgent.php';
``` php
// include classes or rely on Composer autoloader
require_once '/path/to/php-user-agent/phpUserAgent.php';
require_once '/path/to/php-user-agent/phpUserAgentStringParser.php';

// Create a user agent
$userAgent = new phpUserAgent();
// Create a user agent
$userAgent = new phpUserAgent();

// Interrogate the user agent
$userAgent->getBrowserName() // firefox
$userAgent->getBrowserVersion() // 3.6
$userAgent->getOperatingSystem() // linux
$userAgent->getEngine() // gecko
// Interrogate the user agent
$userAgent->getBrowserName() // firefox
$userAgent->getBrowserVersion() // 3.6
$userAgent->getOperatingSystem() // linux
$userAgent->getEngine() // gecko
```

## Advanced

Expand All @@ -45,34 +50,40 @@ It is performant as well, since it doesn't do any iteration or recursion.
When you create a phpUserAgent object, the current user agent string is used.
You can specify another user agent string:

// use another user agent string
$userAgent = new phpUserAgent('msnbot/2.0b (+http://search.msn.com/msnbot.htm)');
$userAgent->getBrowserName() // msnbot
``` php
// use another user agent string
$userAgent = new phpUserAgent('msnbot/2.0b (+http://search.msn.com/msnbot.htm)');
$userAgent->getBrowserName() // msnbot

// use current user agent string
$userAgent = new phpUserAgent($_SERVER['HTTP_USER_AGENT');
// this is equivalent to:
$userAgent = new phpUserAgent();
// use current user agent string
$userAgent = new phpUserAgent($_SERVER['HTTP_USER_AGENT');
// this is equivalent to:
$userAgent = new phpUserAgent();
```

### Custom parser class

By default, phpUserAgentStringParser is used to analyse the user agent string.
You can replace the parser instance and customize it to match your needs:

// create a custom user agent string parser
class myUserAgentStringParser extends phpUserAgentStringParser
{
// override methods
}
``` php
// create a custom user agent string parser
class myUserAgentStringParser extends phpUserAgentStringParser
{
// override methods
}

// inject the custom parser when creating a user agent:
$userAgent = new phpUserAgent(null, new myUserAgentStringParser());
// inject the custom parser when creating a user agent:
$userAgent = new phpUserAgent(null, new myUserAgentStringParser());
```

## Run tests

You can run the unit tests on your server:

php prove.php
``` bash
$ php prove.php
```

## Contribute

Expand Down

0 comments on commit 9c6ae12

Please sign in to comment.