The constructor

$detect = new MobileDetect(?CacheInterface $cache = null, array $config = [])

The constructor can receive an optional cache class compatible with Psr\SimpleCache\CacheInterface

The constructor can also receive optional $config variables as follows:

Variable name
Default value
Description

autoInitOfHttpHeaders

true

Auto-initialization on HTTP headers from $_SERVER['HTTP...']. Disable this if you're going for performance and you want to manually set the User-Agent via $detect->setUserAgent(...)

maximumUserAgentLength

500

Maximum HTTP User-Agent value allowed.

cacheKeyFn

sha1

Method of encoding the cache key.

cacheTtl

86400

Default expiration date for the default Cache class implementation.

Last updated