Agent Class
The agent class allows you to retrieve information about browser type, version, platform or operating system, etc, based on the clients User Agent string.
Configuration
The agent class uses the PHP function get_browser(), which attempts to determine the capabilities of the user's browser, by looking up the browser's information in the browscap.ini file.
The following global configuration values can be defined:
Param | Type | Default | Description |
---|---|---|---|
browscap | array |
|
browscap.ini retrieval configuration. |
cache | array |
|
browscap.ini caching configuration. |
Browscap.ini configuration
If PHP has not been configured to use the browscap.ini file, the agent class will retrieve the file from the location defined in the config/agent.php config file, and cached locally for re-use. This cache will be updated on a regular basis, based on the timeout value defined in the configuration.
Param | Type | Default | Description |
---|---|---|---|
enabled | boolean |
|
Enable download of the browscap.ini file. If disabled, and PHP has not been configured to the browscap functionality through get_browser(), browser detection is disabled, and the agent class will return 'unknown'. |
method | string |
|
Method used to retrieve the browscap.ini file. Supported methods are:
|
url | string |
|
For the methods 'wrapper', 'curl' and 'sockets', the url to download an update of the browscap.ini file. |
proxy | array |
|
See below. |
file | string |
|
For the method 'local', the name and location of the browscap.ini file on a local storage system. |
Proxy configuration
If your server requires the use of a forward proxy to access the internet, you can configure that as part of the browscap settings.
Param | Type | Default | Description |
---|---|---|---|
host | string |
|
Hostname or IP address of your forward proxy. Do NOT include a scheme, so 'proxy.example.org', not 'http://proxy.example.org'. |
port | integer |
|
TCP port your proxy listens on. Common ports are 3128 (Squid) and 8080 (commercial proxies, ISA-2006+) or 80 (ISA-2004). |
auth | string |
|
Authentication method for your proxy. Supported methods are:
|
username | string |
|
Username required for proxy authentication. |
password | string |
|
Password required for proxy authentication. |
Cache configuration
It the agent class is configured to process a browscap.ini file, it will cache the result of both the ini file parser and individual user agent requests in order to increase the response time of the class. These configuration settings determine how the data is cached. For more information, see the Cache class documentation.
Param | Type | Default | Description |
---|---|---|---|
driver | string |
|
Cache driver to use to cache the agent data. If you leave this empty, the default cache driver, configured in the cache configuration, will be used. |
expiry | integer |
|
Number of seconds until the cached data expires. By default, this is 7 days, since the browscap.ini file doesn't change that often. It is recommended not to refresh more frequent than once a day.
The minumum setting is 7200 seconds (two hours), your server will be banned from the browscap website if you download more often! |
identifier | string |
|
Prefix to name of the cache. |