Code Monkey home page Code Monkey logo

51degrees-php7's Introduction

Absolute

This extension is absolute because php-cpp introduces great memory leak, newest php-cpp version is not fully ported to php7, it contains many bugs. please use my new extension: https://github.com/whatvn/php7-51degrees

51Degrees-PHP7

The origin php extension provided by 51Degrees foundation was built on top of swig, which is currently does not support PHP7. This extension is experimental version, build on top of PHP-CPP, working with PHP7, tested with newest php 7 version.

BUILD

Install php-cpp then

make

CONFIGURATION

I tried to keep the same configuration with old 51Degrees php extension, so the configuration file is the same (except extention name)

php.ini

extension=51Degree-PHP7.so
FiftyOneDegreesPatternV3.data_file=/data/51Degrees-LiteV3.2.dat
FiftyOneDegreesPatternV3.property_list=BrowserName,BrowserVersion,PlatformName,PlatformVersion,DeviceType,IsTablet,IsMobile,ScreenPixelsWidth,ScreenPixelsHeight
FiftyOneDegreesPatternV3.cache_size=20000
FiftyOneDegreesPatternV3.pool_size=25

Usage

Internally this extension use getMatchJson api to parse device information, but I keep the same api interface with old 51Degrees extension. here is example:

<?php

$fi = FiftyOneDegreesPatternV3::provider_get();


for ($i=0; $i < 1000000; $i++) {
echo "$i\n";
$match =  $fi->getMatch("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36");
echo $match->getValue("BrowserName");
echo "\n";

echo $match->getValue("PlatformName");
echo "\n";
sleep(0.5);
}

Limitation

PHP-CPP haven't been able to work with php with thread-safe enabled (compile with --enable-maintainer-zts ) So in case anyone use php with zts enabled, please do not try this extension, and php-cpp until they fix this issue: CopernicaMarketingSoftware/PHP-CPP#266

CREDITs:

LICENSE

As always, do whatever you want ;) I do this to learn thing only

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.