NYCPHP Meetup

NYPHP.org

[nycphp-talk] Browser detection

Rainelemental rainelemental at gmail.com
Wed May 1 18:23:03 EDT 2013


I can't run JS and I didn't find any good PHP solution.

I googled and networked around for sometimes, it looks like browser detection is just messed up because the browser finger prints don't have a standard. 

So, the best solution I found is definitely the online user-agent-string.info API, which is accurate but slow and unreliable because the site is slow and often down. They also provide an ugly but working PHP library that download the browser definition file, which is faster but accurate. Although again it does not provide the platform (iPhone...).

So in conclusion, I've create the sail\useragent, because I needed a solution and because it was a fun challenge!

From my iPhone

On May 1, 2013, at 5:24 PM, Darryle Steplight <dsteplight at gmail.com> wrote:

> It looks like Detector just uses modenizer some how behind the scenes. Kind of cheating? Federico have you looked into Phantom.js yet?
> 
> 
> On Wed, May 1, 2013 at 5:08 PM, Brian O'Connor <gatzby3jr at gmail.com> wrote:
>> This might be useful for you: https://github.com/dmolsen/Detector
>> 
>> 
>> On Wed, May 1, 2013 at 3:55 PM, Anthony Ferrara <ircmaxell at gmail.com> wrote:
>>> The best way to do browser detection is to not do it. It's unreliable and difficult to even come close to trying it.
>>> 
>>> Why do you want detection?
>>> 
>>> Anthony
>>> 
>>> 
>>> On Wed, May 1, 2013 at 3:51 PM, Federico Ulfo <rainelemental at gmail.com> wrote:
>>>> Hi all, how do you solve the problem of the browser detection?
>>>> 
>>>> The PHP built in function get_browser() doesn't seams to work very well, it's slow and inaccurate, it also need a huge browscap.ini file to be loaded and updated, and looks like isn't maintained really well.
>>>> 
>>>> The most accurate library I've found uses the user-agent-string.info API, which isn't very fast, and it doesn't tell the device type, such as iPhone, iPad, Android, etc.
>>>> 
>>>> Not satisfacted by the available solutions I've decided to create a library that with dependency injection loads other parser, so it's flexible and accurate. The library, Sail\Useragent, is open source and available on packagist:
>>>> https://github.com/rainphp/useragent
>>>> 
>>>> 
>>>> _______________________________________________
>>>> New York PHP User Group Community Talk Mailing List
>>>> http://lists.nyphp.org/mailman/listinfo/talk
>>>> 
>>>> http://www.nyphp.org/show-participation
>>> 
>>> 
>>> _______________________________________________
>>> New York PHP User Group Community Talk Mailing List
>>> http://lists.nyphp.org/mailman/listinfo/talk
>>> 
>>> http://www.nyphp.org/show-participation
>> 
>> 
>> 
>> -- 
>> Brian O'Connor
>> 
>> _______________________________________________
>> New York PHP User Group Community Talk Mailing List
>> http://lists.nyphp.org/mailman/listinfo/talk
>> 
>> http://www.nyphp.org/show-participation
> 
> 
> 
> -- 
> ----------------------------------------------
> "May the source be with you."
> _______________________________________________
> New York PHP User Group Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
> 
> http://www.nyphp.org/show-participation
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20130501/3be63cf5/attachment.html>


More information about the talk mailing list