serbanghita / Mobile-Detect

Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.
http://mobiledetect.net
MIT License
10.56k stars 2.68k forks source link

Desktop detection and get_browser #33

Closed toneplex closed 3 years ago

toneplex commented 11 years ago

Since browscap doesn't have the ability to distinguish between a phone and a tablet, it would be very nice to replace browscap with mobile-detect. Do you have any plans to add desktop detection, OS version, etc. to mobile-detect?

Specifically, my need would be for the following array:

Array ( [platform] => WinXP [browser] => Firefox [version] => 0.9 [majorver] => 0 [minorver] => 9 );

nodeGarden commented 11 years ago

I second request for Platform.

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11

serbanghita commented 11 years ago

@toneplex @nodeGarden yes, I'm focusing on it as we speak, these features (see also: https://github.com/serbanghita/Mobile-Detect/wiki) will be available in the v.3.0

matthewsuan commented 11 years ago

yeah server side detection at its best. on the other note, is there a version for mobiledetect in ruby, asp and python?

serbanghita commented 11 years ago

@matthewsuan - I know of http://pypi.python.org/pypi/pymobiledetect ; check https://github.com/serbanghita/Mobile-Detect#projects-that-are-using-the-class

nicktacular commented 11 years ago

I'm at odds with myself on this one because of these two contesting issues:

  1. An array is simple but not nearly as elegant as a value object. Doesn't require anything other than returning an array. But you always need to do checks like array_key_exists() or isset() and that's not DRY.
  2. Value objects are awesome. Enough said. However, you need to define these objects somewhere and suddenly a 1-class project is 5 classes (arbitrary number). But it's beautiful and you can do stuff like $mobileDetect->getDevice()->getPlatform() without being un-DRY.

Thoughts?

serbanghita commented 11 years ago

@nicktacular yes, agree, but it should also be noob-friendly. Check my proposal: https://github.com/serbanghita/Mobile-Detect/wiki/Road-to-3.0.0 (see what()) Also see:https://github.com/tobie/ua-parser/issues/294

Maybe we can do them both. I really like the $mobileDetect->getDevice()->getPlatform(), because you always work in a context, but we should also have a dump/dumb result available.

What do you think?

serbanghita commented 3 years ago

https://github.com/serbanghita/Mobile-Detect/issues/15#issuecomment-782725480

I experimented with this, see https://github.com/serbanghita/Mobile-Detect/tree/devel-3-workinprogress/lib, and it's very hard to maintain. I'll keep the a tight focus to Mobile Detect, and that is to detect the mobile environment and focus on the separation of mobiles vs tablets.