Added by Christer Edvartsen, last edited by Christer Edvartsen on May 07, 2008  (view change) show comment

Labels

 
(None)
Under Construction

This proposal is under construction and is not ready for review.

Zend Framework: Zend_UserAgent Component Proposal

Proposed Component Name Zend_UserAgent
Developer Notes http://framework.zend.com/wiki/display/ZFDEV/Zend_UserAgent
Proposers Christer Edvartsen
Revision 0.1 - 23 January 2008: Created initial proposal page (wiki revision: 9)

Table of Contents

1. Overview

Zend_UserAgent will let the user gain more knowledge of the user agent. Zend_UserAgent can inform you if the user is using a mobile phone, a regular browser, or if it is some other kind of device.

2. References

3. Component Requirements, Constraints, and Acceptance Criteria

  • This component will figure out the type of the user agent; browser, mobile, rss reader, robot and so on

4. Dependencies on Other Framework Components

  • Zend_Exception

5. Theory of Operation

6. Milestones / Tasks

7. Class Index

  • Zend_UserAgent
  • Zend_UserAgent_Exception

8. Use Cases

9. Class Skeletons

Good idea!
It is also will be useful try to detect browser/robot type (IE, Opera, Mozilla, etc) and version, xHTML, Javascript support by UA string.

Also noteworthy: http://browsers.garykeith.com/

Seeing Pavel's comment, I'd expect that people want to add more functionality (vendor, version, accept* headers etcetera). Maybe use a plug-in architecture to allow other information to be gathered and queried?

This is useful database with mobile user agents http://wurflpro.com/

Posted by Roman at Mar 07, 2008 06:34

Hi, that's my first post over here, so I'm sorry if I got something wrong ^^.
Why using class constants for storing the type of the user agent?
Altough it is a good idea, what if a different useragents are available?
Does the developer should work with the constant TYPE_UNKNOWN? And then what if the past unknown useragent is added to the recognized type of user agents by this class?
Should the developer rewrite her code?

I think in this case using a object to identify the user agent could be better because of further modifications to the class are not needed, instead, she can create new classes that implements a specific interface to add new types of user agents or to customize the recognized user agents.
Something that behaves like the Null Object Pattern or Strategy pattern should do the job very well.
For instance:

In that way also informations about the user agent can be provided!
I know a library that permits to retrieve user agents information, give it a look: http://garetjax.info/projects/browscap/

I hope my comment can be helpful!

Christer, it appears that the community is already providing feedback on this proposal. Is it ready for review? If so, please reparent it and announce on the mailing list.

Thanks.
,Wil

It's not yet ready for review. I have had too much on my hands lately but will start doing some more work on the component soon. I will reparent it when it's ready.

Argh. I already wrote a really awesome implementation of this, but it's proprietary. I can give you some tips, however:

  • Pluggable data sources
  • Knowing specifics about the browser on the server side is not terribly useful; look at DeviceAtlas and WURFL
  • You can't predict every bit of information a user might want to get if they wish to create custom data sources, so your interfaces must be very generalized

Your proposal, as it currently stands, doesn't seem that useful. Capabilities are what users want to know.

The proposal is pretty outdated as I have been doing some restructuring of the component but I haven't had enough time on my hands to finish things up.

Is this proposal dead ? hope not :|

I think this component could be very useful. For example Zend_Session. Cookies are send based on old 'Expires' method - if session time is set to low value and client and server are in different timezones, cookie could expire before it's date. Detecting UA allows You to use 'Max-Age' for modern browsers. You also need to remember to secure this string as it could be everything.

Posted by Marek at Aug 23, 2008 00:41

I suggest to use browscap.ini to gather all available information. See:

http://www.php.net/manual/en/function.get-browser.php
http://browsers.garykeith.com/downloads.asp

I don't agree. Parsing .ini files is quite slow and requires another dependency that is not needed (and also needs to be updated).