- Prerequisites
- Premium Data
- Getting Started
- Summary
- Distributions
- 51Degrees.php Config
- Using the Detector
- Advanced Usage
- Accessing Metadata
- Image Optimiser
- Client Side Overrides
- Passing Properties To Client Side
- User Performance Monitoring
- Usage Sharing
- Automatic Data Updates
- Advanced Suggestions
- Troubleshooting
Building the PHP Extension
The 51 Degrees PHP extension API builds upon our C API. The 51Degrees API for C can be built into a native extension for C, allowing much faster detection (over 100x faster) and reduced server load. This guide covers how to build and install the extension for Linux. Mac OS X and Windows are not currently supported.
The source code for the PHP extension is distributed alongside the source code of the C API and is located within the php directory of version 3 C distribution. This can be downloaded from GitHub or SourceForge . Download and unzip onto your Linux machine, then follow the relevant instructions for your OS.
For Debian based Linux OSs (eg, Ubuntu, Linux Mint)
Check GCC, make, PHP and PHP dev tools are installed on your Linux machine prior to build. Then in a terminal, run:
apt-get install gcc apt-get install make apt-get install php5 apt-get install php5-dev
Assuming no errors, navigate to php subdirectory of the C API in a terminal. Then run following commands will then build and install the extension:
phpize5 ./configure make install
This will build and copy the extension binary into your server's extension directory.
For Fedora based Linux OSs (eg, RHEL, CentOS, Amazon Linux AMI)
Check GCC, make, PHP and PHP dev tools are installed on your Linux machine prior to build. Then in a terminal, run:
yum install gcc yum install make yum install php yum install php-devel
Assuming no errors, navigate to the C API in a terminal. Copy the entire 'src' folder from the root of the C API directory into the php subdirectory. Then navigate to the 'php' subdirectory and run following commands will then build and install the extension:
phpize ./configure make install
This will build and copy the extension binary into your server's extension directory.
Configuring the Extension
Once the extension is built, your PHP server will need some changes to php.ini. See the Usage guide for information on how to do this and how to access device data.