API_ID
API_ID = 1
The DeviceAtlas device detection API provides a way to detect devices based on the HTTP headers. Using the headers, the API returns device properties such as screen width, screen height, is mobile, vendor, model etc.<br/><br/>
...
__construct(\DeviceAtlas\Device\Config|null $config = null)
Constructs a DeviceApiWeb instance with default or custom config.
\DeviceAtlas\Device\Config|null | $config | An instance of Config, you can change the DeviceAtlas API config by creating an instance of Config and setting your custom config values and then passing the instance to the DeviceApi constructor. null=use default configs. |
loadDataFromFile( $jsonDataFilePath)
$jsonDataFilePath |
saveDataToCache( $jsonDataFilePath)
$jsonDataFilePath |
getPropertyNames() : array
Get a set of all possible property names. Note that the client side properties are not included in this set.
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275A set of all possible device property names as PropertyName objects.
getApiVersion() : string
The version of this API.
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275DeviceApi version
getDataVersion() : string
The version of the data file.
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275The device data file version.
getDataCreationTimestamp() : integer
The creation date/time of the loaded data file as a Unix timestamp.
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275The creation date/time of this data file as a Unix timestamp.
getDataCreationIso8601() : string
The creation date/time of the loaded data file in ISO 8601 format.
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275The creation date/time of the loaded data file in ISO 8601 format.
getProperties(string|array $identifierOrHeaders = null, $clientSideString = null) : \DeviceAtlas\Properties
Get the Device properties for the current request. The most suitable request headers are extracted and used for detection and property lookup.
The DeviceAtlas Client-side component (JavaScript library) collects the client-side properties and puts them in a cookie. The contents of this cookie must be passed to this method. The client properties will override any properties discovered from the main JSON data file.
string|array | $identifierOrHeaders | An identifier such as a User-Agent or Client Hints model, or map of HTTP headers. |
$clientSideString |
A set of properties (Property objects) wrapped in a Properties object
downloadAndLoadDataFile( $dataFileDownloadUrl)
$dataFileDownloadUrl |
buildDataFile( $dataFileDownloadUrl)
$dataFileDownloadUrl |
downloadAndLoadDataFileFromUrl( $dataFile, $dataFileManager = null)
Load the DeviceAtlas data file data from a URL.
Schedule a reload if data file is stale. Re-download data file if local data file is corrupted.
$dataFile | ||
$dataFileManager |
when there is a problem downloading or loading the data file.
scheduleReloadAndFinishRequest( $dataFile, $dataFileManager)
A secondary register_shutdown_call to make sure the reload method is called as the last one; when available call fastcgi_finish_request() too, to make sure there is no delay for a visitor/client.
$dataFile | ||
$dataFileManager |
reload( $dataFile, $dataFileManager, $isScheduled = false)
Downloads a new data file if the existing one is stale.
Loads data file into API.
$dataFile | ||
$dataFileManager | ||
$isScheduled |
getDataFromFile( $jsonDataFilePath)
$jsonDataFilePath |
loadDataFromCache( $jsonDataFilePath, $refreshCache = false)
$jsonDataFilePath | ||
$refreshCache |
loadCachedTreeRoot()
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
postLoadDataInitialization()
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
getPropertiesFromHeaders( $headers, $clientSideString = null)
$headers | ||
$clientSideString |
extractLanguageProperties( $properties, $acceptLanguageHeader)
$properties | ||
$acceptLanguageHeader |
getAcceptLanguage( $normalisedHeaders)
$normalisedHeaders |
getPropertiesFromIdentifier(string $identifier, $clientSideString = null) : \DeviceAtlas\Properties
Get the properties for a User-Agent merged with the client-side properties (when provided by the DeviceAtlas client side component).
The DeviceAtlas client-side component (JavaScript library) collects the client-side properties and puts them in a cookie. The contents of this cookie must be passed to this method. The client properties will over-ride any properties discovered from the main JSON data file.
string | $identifier | The User-Agent string |
$clientSideString |
A set of properties (Property objects) wrapped in a Properties object
detectProperties( $normalisedHeaders, $clientSideString = null)
$normalisedHeaders | ||
$clientSideString |
extractClientSideInputs( $dynamicProperties, $normalisedHeaders)
The client side string may contain identifiers that can be used for component detection. This method adds these identifiers to the headers map.
$dynamicProperties | ||
$normalisedHeaders |
normaliseHeaders( $headers)
Performs the following on header keys: lowercase, replaces "_" with "-" and strips prefixed "http-" if present.
$headers |
checkIsDataLoaded()
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275
cachePut( $identifierOrHeaders, $clientSideString, $properties, $acceptLanguage = null)
$identifierOrHeaders | ||
$clientSideString | ||
$properties | ||
$acceptLanguage |
cacheGet( $identifierOrHeaders, $clientSideString, $acceptLanguage = null)
$identifierOrHeaders | ||
$clientSideString | ||
$acceptLanguage |
checkReloadSchedule( $dataFile, $dataFileManager, $forceReload = false)
$dataFile | ||
$dataFileManager | ||
$forceReload |
callFailureCallback(\Exception $ex, $dataFile)
Call user defined callback if set.
\Exception | $ex | |
$dataFile |