Agent クラス
The agent class allows you to retrieve information about browser type, version, platform or operating system, etc, based on the clients User Agent string.
設定
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:
パラメータ | 型 | 規定値 | 説明 |
---|---|---|---|
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.
パラメータ | 型 | 規定値 | 説明 |
---|---|---|---|
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. |
file | string |
|
For the method 'local', the name and location of the browscap.ini file on a local storage system. |
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.
パラメータ | 型 | 規定値 | 説明 |
---|---|---|---|
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 |
|
For the methods 'wrapper', 'curl' and 'sockets', the url to download an update of the browscap.ini file. |