• About Us
  • Blog
  • Basket
  • Account
  • Sign In
  •  

PHP API

Configuring the PHP API

Before using the extension you must supply the PHP environment with information on the location of the module and the module parameters. This should be done by editing your PHP.ini file.

If you are not sure where the PHP.ini file is located on your system you can create a .php page and place in your server directory. Add the following php code to the page

<!--?php
phpinfo();
?-->

and look for the 'php.ini' file location.

Open the 'php.ini' file and add the following to the bottom. Please note that superuser privileges will probably be required to edit the file.

The first parameter is the location of the extension binary (note that your location may be different from the one here. Check for the location). The second is the is the path to the 51Degrees data file. The third parameter defines the number of WorkSet items in the pool. Make sure that it is in a location that Apache has read permissions for.

extension=/usr/lib/php5/FiftyOneDegreesPatternV3.so
FiftyOneDegreesPatternV3.data_file=path/to/51Degrees/data/file.dat
FiftyOneDegreesPatternV3.property_list=BrowserName,BrowserVendor,
   BrowserVersion,DeviceType,HardwareVendor,IsTablet,IsMobile,
   IsCrawler,ScreenInchesDiagonal,ScreenPixelsWidth
FiftyOneDegreesPatternV3.cache_size=10000
FiftyOneDegreesPatternV3.pool_size=20
Setting Description
Common Settings
extension This setting tells the PHP environment where the compiled extension is located.
Pattern settings
FiftyOneDegreesPatternV3.data_file This setting tells the extension where the 51Degrees Pattern data file is located. Pattern data files have the '.dat' file extension. Make sure the file is uncompressed and is accessible by your PHP environment.
FiftyOneDegreesPatternV3.property_list This is essentially a list of properties you wish the dataset to be initialized with. Premium data file provides over 130 properties and Enterprise over 160 properties. This setting allows you to only choose properties you are interested in. Leaving this setting line empty or not including it at all will return a full list of properties in detection results.
FiftyOneDegreesPatternV3.cache_size This setting tells the detector how many elements should be cached. Cache helps to speed up device detection by keeping a list of the most frequently encountered devices in memory, hence reducing the amount of requests to the device data.
FiftyOneDegreesPatternV3.pool_size This setting tells the detector how many worksets the detector should use. Worksets are used to keep the information associated with the request and detection results. A workset is drawn from the pool when a request commences and is released back to the pool upon request end.
Trie Settings
FiftyOneDegreesTrieV3.data_file This setting tells the extension where the 51Degrees Trie data file is located. Pattern data files have the '.trie' file extension. Make sure the file is uncompressed and is accessible by your PHP environment.
FiftyOneDegreesTrieV3.property_list This is essentially a list of properties you wish the dataset to be initialized with. Premium data file provides over 130 properties and Enterprise over 160 properties. This setting allows you to only choose properties you are interested in. Leaving this setting line empty or not including it at all will return a full list of properties in detection results.