问题
I am looking to do some device detection in PHP and I am looking into a few options. The one that looks the best right now is WURFL http://wurfl.sourceforge.net/. But I am very leery of it because of its non open source license. I am also wondering if it is even relevant because the documentation websites look kind of dated.
Other options like WURFL include http://deviceatlas.com/ and http://51degrees.mobi/ but neither of these are even close to open source.
Then there are the PHP only solutions like http://detectmobilebrowsers.mobi , http://code.google.com/p/php-mobile-detect/ and http://detectmobilebrowsers.com/ but these all use some form of regex that looks ugly.
The ideal solution for me would be an open source XML file or database that I can store locally, and that can be updated as needed.
Am I dreaming? What solution do you prefer for detecting mobile users?
回答1:
Any reason not to use the ua-parser project?
The PHP client is here: https://github.com/tobie/ua-parser/tree/master/php
回答2:
Sorry to revive a dead post but there is an Open Source Alternative - OpenDDR - but I can't find PHP libraries for it yet so you will need to code your own parse and search routines.
回答3:
I use a script based on the work at http://detectmobilebrowsers.com/. It boils down to a regular expression, which is supported in pretty much any language, not just PHP. As regex's go, it's not even terribly ugly: the main one is only a few lines long, and would be extremely quick to parse in most languages/frameworks. Being a regex, it's totally transparent, and doesn't require you to install some librarly, DLL, or DB/file-based repository.
The author, Chad Smith, uses the WURFL database to compile a stripped-down, minimalist Regex to detect only mobile browsers. Tablets are excluded on the assumption that they will usually work well with the desktop version of a page. He seems to update it once a year, or at least whenever a new major mobile browser comes out (which is not very often.)
回答4:
It's easy to add Tablet browser detect to Chad Smith's regex's, and it seems to work well. See the about section:
http://detectmobilebrowsers.com/about
回答5:
I use MobileESP which is not as advanced as WURFL, but does the trick for my needs. There is no separate database in MobileESP that you can upgrade, you have to upgrade the whole library.
回答6:
If you only need device categorisation - e.g. mobile, desktop or tablet - then Categorizr is probably the best option. It takes a mobile first approach as it is easier to identify the small and relatively stable population of desktop browsers than the vast number of mobile and other browsers.
来源:https://stackoverflow.com/questions/9673535/best-open-source-wurfl-alternative