.mddoc.xml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <mddoc>
  2. <docpage target="README.md" autoloader="psr0" autoloader-root="src">
  3. <section title="PHP User Agent Parser">
  4. <text><![CDATA[
  5. [![Join the chat at https://gitter.im/PhpUserAgentParser/Lobby](https://badges.gitter.im/PhpUserAgentParser/Lobby.svg)](https://gitter.im/PhpUserAgentParser/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
  6. ]]></text>
  7. <badge-poser type="version"/>
  8. <badge-poser type="downloads"/>
  9. <badge-poser type="license"/>
  10. <badge-travis name="donatj/phpUserAgent"/>
  11. <badge-github-action name="donatj/phpUserAgent" workflow="CI"/>
  12. <section title="What It Is">
  13. <text><![CDATA[
  14. A simple, streamlined PHP user-agent parser!
  15. Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
  16. ]]></text>
  17. </section>
  18. <section title="Upgrading to `1.*`">
  19. <text><![CDATA[
  20. The new `1.*` release **does not break compatibility** with `0.*` and nothing need to change to upgrade. However, the global `parse_user_agent` is now deprecated; it has been replaced with the namespaced `\donatj\UserAgent\parse_user_agent` and functions exactly the same. You can easily replace any existing call to `parse_user_agent` with `\donatj\UserAgent\parse_user_agent`
  21. In addition, 1.x adds a convenience object wrapper you may use should you prefer. More information on this is in the Usage section below.
  22. ]]></text>
  23. </section>
  24. <section title="Why Use This">
  25. <text><![CDATA[
  26. You have your choice in user-agent parsers. This one detects **all modern browsers** in a very light, quick, understandable fashion.
  27. It is less than 200 lines of code, and consists of just three regular expressions!
  28. It can also correctly identify exotic versions of IE others fail on.
  29. It offers 100% unit test coverage, is installable via Composer, and is very easy to use.
  30. ]]></text>
  31. </section>
  32. <section title="What It Does Not Do">
  33. <text><![CDATA[
  34. This is not meant as a browser "knowledge engine" but rather a simple parser. Anything not adequately provided directly by the user agent string itself will simply not be provided by this.
  35. ]]></text>
  36. <section title="OS Versions">
  37. <text><![CDATA[
  38. User-agent strings **are not** a reliable source of OS Version!
  39. - Many agents simply don't send the information.
  40. - Others provide varying levels of accuracy.
  41. - Parsing Windows versions alone almost nearly doubles the size of the code.
  42. I'm much more interested in keeping this thing *tiny* and accurate than adding niché features and would rather focus on things that can be **done well**.
  43. All that said, there is the start of a [branch to do it](https://github.com/donatj/PhpUserAgent/tree/os_version_detection) I created for a client if you want to poke it, I update it from time to time, but frankly if you need to *reliably detect OS Version*, using user-agent isn't the way to do it. I'd go with JavaScript.
  44. ]]></text>
  45. </section>
  46. <section title="Undetectable Browsers">
  47. <text><![CDATA[
  48. - **Brave** - Brave is simply not differentiable from Chrome. This was a design decision on their part.
  49. ]]></text>
  50. </section>
  51. </section>
  52. <section title="Requirements">
  53. <composer-requires/>
  54. </section>
  55. <section title="Installing">
  56. <text>PHP User Agent is available through Packagist via Composer.</text>
  57. <composer-install/>
  58. </section>
  59. <section title="Usage">
  60. <text><![CDATA[
  61. The classic procedural use is as simple as:
  62. ```php
  63. $ua_info = parse_user_agent();
  64. /*
  65. array(
  66. 'platform' => '[Detected Platform]',
  67. 'browser' => '[Detected Browser]',
  68. 'version' => '[Detected Browser Version]',
  69. );
  70. */
  71. ```
  72. ]]></text>
  73. <text><![CDATA[
  74. The new object oriented wrapper form:
  75. ```php
  76. $parser = new UserAgentParser();
  77. $ua = $parser->parse();
  78. // or
  79. $ua = $parser();
  80. $ua->platform();
  81. $ua->browser();
  82. $ua->browserVersion();
  83. ```
  84. ]]></text>
  85. </section>
  86. <section title="Currently Detected Platforms">
  87. <exec cmd="php .helpers/constants.php 'donatj\UserAgent\Platforms' 'Platform'"/>
  88. </section>
  89. <section title="Currently Detected Browsers">
  90. <exec cmd="php .helpers/constants.php 'donatj\UserAgent\Browsers' 'Browser'"/>
  91. </section>
  92. <text><![CDATA[
  93. More information is available at [Donat Studios](http://donatstudios.com/PHP-Parser-HTTP_USER_AGENT).
  94. ]]></text>
  95. </section>
  96. </docpage>
  97. </mddoc>