Usage-Installation.html 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <!DOCTYPE html>
  2. <html class="writer-html5" lang="en" >
  3. <head>
  4. <meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>Installation &mdash; PHP-QRCode main
  7. Manual</title>
  8. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  9. <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  10. <!--[if lt IE 9]>
  11. <script src="_static/js/html5shiv.min.js"></script>
  12. <![endif]-->
  13. <script src="_static/jquery.js"></script>
  14. <script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
  15. <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
  16. <script src="_static/doctools.js"></script>
  17. <script src="_static/sphinx_highlight.js"></script>
  18. <script src="_static/js/theme.js"></script>
  19. <link rel="index" title="Index" href="genindex.html" />
  20. <link rel="search" title="Search" href="search.html" />
  21. <link rel="next" title="Quickstart" href="Usage-Quickstart.html" />
  22. <link rel="prev" title="Overview" href="Usage-Overview.html" />
  23. </head>
  24. <body class="wy-body-for-nav">
  25. <div class="wy-grid-for-nav">
  26. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  27. <div class="wy-side-scroll">
  28. <div class="wy-side-nav-search" >
  29. <a href="index.html" class="icon icon-home">
  30. PHP-QRCode
  31. </a>
  32. <div role="search">
  33. <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
  34. <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
  35. <input type="hidden" name="check_keywords" value="yes" />
  36. <input type="hidden" name="area" value="default" />
  37. </form>
  38. </div>
  39. </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
  40. <p class="caption" role="heading"><span class="caption-text">Usage</span></p>
  41. <ul class="current">
  42. <li class="toctree-l1"><a class="reference internal" href="Usage-Overview.html">Overview</a><ul>
  43. <li class="toctree-l2"><a class="reference internal" href="Usage-Overview.html#features">Features</a></li>
  44. <li class="toctree-l2"><a class="reference internal" href="Usage-Overview.html#requirements">Requirements</a></li>
  45. <li class="toctree-l2"><a class="reference internal" href="Usage-Overview.html#framework-integration">Framework Integration</a></li>
  46. </ul>
  47. </li>
  48. <li class="toctree-l1 current"><a class="current reference internal" href="#">Installation</a><ul>
  49. <li class="toctree-l2"><a class="reference internal" href="#installation-with-composer">Installation with Composer</a><ul>
  50. <li class="toctree-l3"><a class="reference internal" href="#composer-json">composer.json</a><ul>
  51. <li class="toctree-l4"><a class="reference internal" href="#version-switch">Version switch</a></li>
  52. </ul>
  53. </li>
  54. <li class="toctree-l3"><a class="reference internal" href="#terminal">Terminal</a></li>
  55. </ul>
  56. </li>
  57. <li class="toctree-l2"><a class="reference internal" href="#manual-installation">Manual installation</a><ul>
  58. <li class="toctree-l3"><a class="reference internal" href="#can-i-use-this-library-without-using-composer">Can i use this library without using composer?</a></li>
  59. </ul>
  60. </li>
  61. <li class="toctree-l2"><a class="reference internal" href="#supported-php-versions-extension-requirements">Supported PHP versions &amp; extension requirements</a></li>
  62. <li class="toctree-l2"><a class="reference internal" href="#imagemagick">ImageMagick</a></li>
  63. </ul>
  64. </li>
  65. <li class="toctree-l1"><a class="reference internal" href="Usage-Quickstart.html">Quickstart</a><ul>
  66. <li class="toctree-l2"><a class="reference internal" href="Usage-Quickstart.html#import-the-library">Import the library</a></li>
  67. <li class="toctree-l2"><a class="reference internal" href="Usage-Quickstart.html#create-your-first-qr-code">Create your first QR Code</a><ul>
  68. <li class="toctree-l3"><a class="reference internal" href="Usage-Quickstart.html#configuration">Configuration</a></li>
  69. </ul>
  70. </li>
  71. <li class="toctree-l2"><a class="reference internal" href="Usage-Quickstart.html#reading-qr-codes">Reading QR Codes</a></li>
  72. <li class="toctree-l2"><a class="reference internal" href="Usage-Quickstart.html#notes">Notes</a></li>
  73. </ul>
  74. </li>
  75. <li class="toctree-l1"><a class="reference internal" href="Usage-Advanced-usage.html">Advanced usage</a><ul>
  76. <li class="toctree-l2"><a class="reference internal" href="Usage-Advanced-usage.html#configuration-via-qroptions">Configuration via <code class="docutils literal notranslate"><span class="pre">QROptions</span></code></a><ul>
  77. <li class="toctree-l3"><a class="reference internal" href="Usage-Advanced-usage.html#supply-an-iterable-of-options">Supply an <code class="docutils literal notranslate"><span class="pre">iterable</span></code> of options</a></li>
  78. <li class="toctree-l3"><a class="reference internal" href="Usage-Advanced-usage.html#load-and-save-json">Load and save JSON</a></li>
  79. <li class="toctree-l3"><a class="reference internal" href="Usage-Advanced-usage.html#extending-the-qroptions-class">Extending the <code class="docutils literal notranslate"><span class="pre">QROptions</span></code> class</a></li>
  80. </ul>
  81. </li>
  82. <li class="toctree-l2"><a class="reference internal" href="Usage-Advanced-usage.html#qrcode-methods"><code class="docutils literal notranslate"><span class="pre">QRCode</span></code> methods</a><ul>
  83. <li class="toctree-l3"><a class="reference internal" href="Usage-Advanced-usage.html#save-to-file">Save to file</a></li>
  84. <li class="toctree-l3"><a class="reference internal" href="Usage-Advanced-usage.html#render-a-qrmatrix-instance">Render a <code class="docutils literal notranslate"><span class="pre">QRMatrix</span></code> instance</a></li>
  85. <li class="toctree-l3"><a class="reference internal" href="Usage-Advanced-usage.html#mixed-mode">Mixed mode</a></li>
  86. <li class="toctree-l3"><a class="reference internal" href="Usage-Advanced-usage.html#qr-code-reader">QR Code reader</a></li>
  87. </ul>
  88. </li>
  89. </ul>
  90. </li>
  91. </ul>
  92. <p class="caption" role="heading"><span class="caption-text">Appendix</span></p>
  93. <ul>
  94. <li class="toctree-l1"><a class="reference internal" href="Appendix-License.html">License</a></li>
  95. </ul>
  96. </div>
  97. </div>
  98. </nav>
  99. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
  100. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  101. <a href="index.html">PHP-QRCode</a>
  102. </nav>
  103. <div class="wy-nav-content">
  104. <div class="rst-content">
  105. <div role="navigation" aria-label="Page navigation">
  106. <ul class="wy-breadcrumbs">
  107. <li><a href="index.html" class="icon icon-home" aria-label="Home"></a></li>
  108. <li class="breadcrumb-item active">Installation</li>
  109. <li class="wy-breadcrumbs-aside">
  110. <a href="https://github.com/chillerlan/php-qrcode/blob/main/docs/Usage-Installation.md" class="fa fa-github"> Edit on GitHub</a>
  111. </li>
  112. </ul>
  113. <hr/>
  114. </div>
  115. <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
  116. <div itemprop="articleBody">
  117. <section id="installation">
  118. <h1>Installation<a class="headerlink" href="#installation" title="Permalink to this heading"></a></h1>
  119. <section id="installation-with-composer">
  120. <h2>Installation with Composer<a class="headerlink" href="#installation-with-composer" title="Permalink to this heading"></a></h2>
  121. <p><strong><a class="reference external" href="https://getcomposer.org">Composer</a> is required to install this package. Please do not open an issue to complain about “monopolizing the implementation” or similar - we’ve been there before.</strong></p>
  122. <section id="composer-json">
  123. <h3>composer.json<a class="headerlink" href="#composer-json" title="Permalink to this heading"></a></h3>
  124. <p>Installation via <a class="reference external" href="https://getcomposer.org/doc/04-schema.md"><code class="docutils literal notranslate"><span class="pre">composer.json</span></code></a>:</p>
  125. <div class="highlight-json notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
  126. <span class="w"> </span><span class="nt">&quot;require&quot;</span><span class="p">:</span><span class="w"> </span><span class="p">{</span>
  127. <span class="w"> </span><span class="nt">&quot;php&quot;</span><span class="p">:</span><span class="w"> </span><span class="s2">&quot;^7.4&quot;</span><span class="p">,</span>
  128. <span class="w"> </span><span class="nt">&quot;chillerlan/php-qrcode&quot;</span><span class="p">:</span><span class="w"> </span><span class="s2">&quot;dev-main&quot;</span>
  129. <span class="w"> </span><span class="p">}</span>
  130. <span class="p">}</span>
  131. </pre></div>
  132. </div>
  133. <p>Note: replace <code class="docutils literal notranslate"><span class="pre">dev-main</span></code> with a <a class="reference external" href="https://getcomposer.org/doc/articles/versions.md#writing-version-constraints">version constraint</a>, e.g. <code class="docutils literal notranslate"><span class="pre">^4.3</span></code> - see <a class="reference external" href="https://github.com/chillerlan/php-qrcode/releases">releases</a> for valid versions.
  134. In case you want to keep using <code class="docutils literal notranslate"><span class="pre">dev-main</span></code>, specify the hash of a commit to avoid running into unforseen issues, like so: <code class="docutils literal notranslate"><span class="pre">dev-main#cb69751c3bc090a7fdd2f2601bbe10f28d225f10</span></code></p>
  135. <section id="version-switch">
  136. <h4>Version switch<a class="headerlink" href="#version-switch" title="Permalink to this heading"></a></h4>
  137. <p>If your application supports older PHP versions and uses the basic <code class="docutils literal notranslate"><span class="pre">QRCode</span></code> syntax <code class="docutils literal notranslate"><span class="pre">(new</span> <span class="pre">QRCode)-&gt;render($data)</span></code>, then you can add a version switch to your <code class="docutils literal notranslate"><span class="pre">composer.json</span></code> to allow installing a <code class="docutils literal notranslate"><span class="pre">php-qrcode</span></code> version that suits the platform it runs on:</p>
  138. <div class="highlight-json notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
  139. <span class="w"> </span><span class="nt">&quot;require&quot;</span><span class="p">:</span><span class="w"> </span><span class="p">{</span>
  140. <span class="w"> </span><span class="nt">&quot;php&quot;</span><span class="p">:</span><span class="w"> </span><span class="s2">&quot;^7.0 || ^8.0&quot;</span><span class="p">,</span>
  141. <span class="w"> </span><span class="nt">&quot;chillerlan/php-qrcode&quot;</span><span class="p">:</span><span class="w"> </span><span class="s2">&quot;^2.0 || ^3.4 || ^4.3 || ^5.0&quot;</span>
  142. <span class="w"> </span><span class="p">}</span>
  143. <span class="p">}</span>
  144. </pre></div>
  145. </div>
  146. <p>Most of the v2.0 API remains unchanged throughout the several versions up to v5.x, however, please test and verify the expected output before you deploy such a switch.</p>
  147. </section>
  148. </section>
  149. <section id="terminal">
  150. <h3>Terminal<a class="headerlink" href="#terminal" title="Permalink to this heading"></a></h3>
  151. <p>To install <code class="docutils literal notranslate"><span class="pre">php-qrcode</span></code> on the terminal, use:</p>
  152. <p><code class="docutils literal notranslate"><span class="pre">composer</span> <span class="pre">require</span> <span class="pre">chillerlan/php-qrcode</span></code></p>
  153. <p>If you want to install the package from a specific tag or commit, do as follows:</p>
  154. <ul class="simple">
  155. <li><p><code class="docutils literal notranslate"><span class="pre">composer</span> <span class="pre">require</span> <span class="pre">chillerlan/php-qrcode:4.3.4</span></code></p></li>
  156. <li><p><code class="docutils literal notranslate"><span class="pre">composer</span> <span class="pre">require</span> <span class="pre">chillerlan/php-qrcode:dev-main#f15b0afe9d4128bf734c3bf1bcffae72bf7b3e53</span></code></p></li>
  157. </ul>
  158. </section>
  159. </section>
  160. <section id="manual-installation">
  161. <h2>Manual installation<a class="headerlink" href="#manual-installation" title="Permalink to this heading"></a></h2>
  162. <p>Download the desired version of the package from <a class="reference external" href="https://github.com/chillerlan/php-qrcode/archive/refs/heads/main.zip">main</a> or
  163. <a class="reference external" href="https://github.com/chillerlan/php-qrcode/releases">release</a> and extract the contents to your project folder.
  164. After that, run <code class="docutils literal notranslate"><span class="pre">composer</span> <span class="pre">install</span></code> in the package root directory to install the required dependencies and generate <code class="docutils literal notranslate"><span class="pre">./vendor/autoload.php</span></code>.</p>
  165. <p>Profit!</p>
  166. <section id="can-i-use-this-library-without-using-composer">
  167. <h3>Can i use this library without using composer?<a class="headerlink" href="#can-i-use-this-library-without-using-composer" title="Permalink to this heading"></a></h3>
  168. <p>You can, but it’s absolutely not recommended, nor supported.</p>
  169. <p>With that said, I’ll leave you with this info:</p>
  170. <ul class="simple">
  171. <li><p>download the .zip for a version of your choice and also all required dependencies listed in the <code class="docutils literal notranslate"><span class="pre">composer.json</span></code> for that version (you can find links to the respective repos <a class="reference external" href="https://packagist.org/packages/chillerlan/php-qrcode">on packagist</a>)</p></li>
  172. <li><p>extract the files into your library folder</p></li>
  173. <li><p>include the files manually or with whatever autoloader you are using</p></li>
  174. </ul>
  175. <p>Good luck!</p>
  176. </section>
  177. </section>
  178. <section id="supported-php-versions-extension-requirements">
  179. <h2>Supported PHP versions &amp; extension requirements<a class="headerlink" href="#supported-php-versions-extension-requirements" title="Permalink to this heading"></a></h2>
  180. <p>The PHP built-in extensions <a class="reference external" href="https://www.php.net/manual/book.image.php">GdImage</a> and <a class="reference external" href="https://www.php.net/manual/book.mbstring.php">mbstring</a> are used across all versions, <a class="reference external" href="https://www.php.net/manual/book.imagick.php">ImageMagick</a> is optional since v3.x.</p>
  181. <table class="docutils align-default">
  182. <thead>
  183. <tr class="row-odd"><th class="head"><p>version</p></th>
  184. <th class="head"><p>branch/tag</p></th>
  185. <th class="head"><p>PHP</p></th>
  186. <th class="head"><p>supported</p></th>
  187. <th class="head"><p>required extensions</p></th>
  188. <th class="head"><p>optional extensions</p></th>
  189. <th class="head"><p>info</p></th>
  190. </tr>
  191. </thead>
  192. <tbody>
  193. <tr class="row-even"><td><p><strong>v5</strong></p></td>
  194. <td><p><a class="reference external" href="https://github.com/chillerlan/php-qrcode/tree/main"><code class="docutils literal notranslate"><span class="pre">dev-main</span></code></a></p></td>
  195. <td><p><code class="docutils literal notranslate"><span class="pre">^7.4 || ^8.0</span></code></p></td>
  196. <td><p>yes</p></td>
  197. <td><p><code class="docutils literal notranslate"><span class="pre">mbstring</span></code></p></td>
  198. <td><p><code class="docutils literal notranslate"><span class="pre">gd</span></code> or <code class="docutils literal notranslate"><span class="pre">imagick</span></code> required for reading QR Codes, <code class="docutils literal notranslate"><span class="pre">fileinfo</span></code> is used in <code class="docutils literal notranslate"><span class="pre">QRImagick</span></code></p></td>
  199. <td><p></p></td>
  200. </tr>
  201. <tr class="row-odd"><td><p><strong>v4</strong></p></td>
  202. <td><p><a class="reference external" href="https://github.com/chillerlan/php-qrcode/tree/v4.3.x"><code class="docutils literal notranslate"><span class="pre">4.3.4</span></code></a></p></td>
  203. <td><p><code class="docutils literal notranslate"><span class="pre">^7.4 || ^8.0</span></code></p></td>
  204. <td><p>yes</p></td>
  205. <td><p><code class="docutils literal notranslate"><span class="pre">gd</span></code>, <code class="docutils literal notranslate"><span class="pre">mbstring</span></code></p></td>
  206. <td><p><code class="docutils literal notranslate"><span class="pre">imagick</span></code></p></td>
  207. <td><p></p></td>
  208. </tr>
  209. <tr class="row-even"><td><p><strong>v3</strong></p></td>
  210. <td><p><a class="reference external" href="https://github.com/chillerlan/php-qrcode/tree/v3.2.x"><code class="docutils literal notranslate"><span class="pre">3.4.1</span></code></a></p></td>
  211. <td><p><code class="docutils literal notranslate"><span class="pre">^7.2</span></code></p></td>
  212. <td><p>no</p></td>
  213. <td><p><code class="docutils literal notranslate"><span class="pre">gd</span></code>, <code class="docutils literal notranslate"><span class="pre">mbstring</span></code></p></td>
  214. <td><p><code class="docutils literal notranslate"><span class="pre">imagick</span></code></p></td>
  215. <td><p>v3.4.1 also supports PHP8</p></td>
  216. </tr>
  217. <tr class="row-odd"><td><p><strong>v2</strong></p></td>
  218. <td><p><a class="reference external" href="https://github.com/chillerlan/php-qrcode/tree/v2.0.x"><code class="docutils literal notranslate"><span class="pre">2.0.8</span></code></a></p></td>
  219. <td><p><code class="docutils literal notranslate"><span class="pre">&gt;=7.0.3</span></code></p></td>
  220. <td><p>no</p></td>
  221. <td><p><code class="docutils literal notranslate"><span class="pre">gd</span></code>, <code class="docutils literal notranslate"><span class="pre">mbstring</span></code></p></td>
  222. <td><p></p></td>
  223. <td><p></p></td>
  224. </tr>
  225. <tr class="row-even"><td><p><strong>v1</strong></p></td>
  226. <td><p><a class="reference external" href="https://github.com/chillerlan/php-qrcode/tree/v2.0.x-php5"><code class="docutils literal notranslate"><span class="pre">1.0.9</span></code></a></p></td>
  227. <td><p><code class="docutils literal notranslate"><span class="pre">&gt;=5.6</span></code></p></td>
  228. <td><p>no</p></td>
  229. <td><p><code class="docutils literal notranslate"><span class="pre">gd</span></code>, <code class="docutils literal notranslate"><span class="pre">mbstring</span></code></p></td>
  230. <td><p></p></td>
  231. <td><p>please let PHP 5 die!</p></td>
  232. </tr>
  233. </tbody>
  234. </table>
  235. <p>PSA: <a class="reference external" href="https://www.php.net/supported-versions.php">PHP versions &lt; 8.0 are EOL</a> and therefore the respective <code class="docutils literal notranslate"><span class="pre">QRCode</span></code> versions are also no longer supported!</p>
  236. </section>
  237. <section id="imagemagick">
  238. <h2>ImageMagick<a class="headerlink" href="#imagemagick" title="Permalink to this heading"></a></h2>
  239. <p>Please follow the installation guides for your operating system:</p>
  240. <ul class="simple">
  241. <li><p>ImageMagick: <a class="reference external" href="https://imagemagick.org/script/download.php">imagemagick.org/script/download.php</a></p></li>
  242. <li><p>PHP <code class="docutils literal notranslate"><span class="pre">ext-imagick</span></code>: <a class="reference external" href="https://github.com/Imagick/imagick">github.com/Imagick/imagick</a></p></li>
  243. </ul>
  244. </section>
  245. </section>
  246. </div>
  247. </div>
  248. <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
  249. <a href="Usage-Overview.html" class="btn btn-neutral float-left" title="Overview" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
  250. <a href="Usage-Quickstart.html" class="btn btn-neutral float-right" title="Quickstart" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
  251. </div>
  252. <hr/>
  253. <div role="contentinfo">
  254. <p>&#169; Copyright 2023, smiley.</p>
  255. </div>
  256. </footer>
  257. </div>
  258. </div>
  259. </section>
  260. </div>
  261. <script>
  262. jQuery(function () {
  263. SphinxRtdTheme.Navigation.enable(true);
  264. });
  265. </script>
  266. </body>
  267. </html>