Installation.md.txt 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # Installation
  2. ## Installation with Composer
  3. **[Composer](https://getcomposer.org) 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.**
  4. ### composer.json
  5. Installation via [`composer.json`](https://getcomposer.org/doc/04-schema.md):
  6. ```json
  7. {
  8. "require": {
  9. "php": "^8.2",
  10. "chillerlan/php-qrcode": "dev-main"
  11. }
  12. }
  13. ```
  14. Note: replace `dev-main` with a [version constraint](https://getcomposer.org/doc/articles/versions.md#writing-version-constraints), e.g. `^4.3` - see [releases](https://github.com/chillerlan/php-qrcode/releases) for valid versions.
  15. In case you want to keep using `dev-main`, specify the hash of a commit to avoid running into unforseen issues, like so: `dev-main#cb69751c3bc090a7fdd2f2601bbe10f28d225f10`
  16. #### Version switch
  17. If your application supports older PHP versions and uses the basic `QRCode` syntax `(new QRCode)->render($data)`, then you can add a version switch to your `composer.json` to allow installing a `php-qrcode` version that suits the platform it runs on:
  18. ```json
  19. {
  20. "require": {
  21. "php": "^7.0 || ^8.0",
  22. "chillerlan/php-qrcode": "^2.0 || ^3.4 || ^4.3 || ^5.0"
  23. }
  24. }
  25. ```
  26. 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.
  27. ### Terminal
  28. To install `php-qrcode` on the terminal, use:
  29. ```shell
  30. composer require chillerlan/php-qrcode
  31. ```
  32. If you want to install the package from a specific tag or commit, do as follows:
  33. ```shell
  34. composer require chillerlan/php-qrcode:4.3.4
  35. composer require chillerlan/php-qrcode:dev-main#f15b0afe9d4128bf734c3bf1bcffae72bf7b3e53
  36. ```
  37. ## Manual installation
  38. Download the desired version of the package from [main](https://github.com/chillerlan/php-qrcode/archive/refs/heads/main.zip) or
  39. [release](https://github.com/chillerlan/php-qrcode/releases) and extract the contents to your project folder.
  40. After that, run `composer install` in the package root directory to install the required dependencies and generate `./vendor/autoload.php`.
  41. Profit!
  42. ### Can I use this library without using composer?
  43. You can, but it's absolutely not recommended, nor supported.
  44. With that said, I'll leave you with this info:
  45. - download the .zip for a version of your choice and also all required dependencies listed in the `composer.json` for that version (you can find links to the respective repos [on packagist](https://packagist.org/packages/chillerlan/php-qrcode))
  46. - extract the files into your library folder
  47. - include the files manually or with whatever autoloader you are using
  48. Good luck!
  49. ## Supported PHP versions & extension requirements
  50. The PHP built-in extensions [GdImage](https://www.php.net/manual/book.image.php) and [mbstring](https://www.php.net/manual/book.mbstring.php) are used across all versions, [ImageMagick](https://www.php.net/manual/book.imagick.php) is optional since v3.x.
  51. | version | branch/tag | PHP | supported | required extensions | optional extensions | info |
  52. |---------|----------------------------------------------------------------------|------------------|-----------|---------------------|------------------------------------------------------------------------------------|---------------------------|
  53. | **v6** | [`dev-main`](https://github.com/chillerlan/php-qrcode/tree/main) | `^8.2` | yes | `mbstring` | `gd` or `imagick` required for reading QR Codes, `fileinfo` is used in `QRImagick` | |
  54. | **v5** | [`5.0.5`](https://github.com/chillerlan/php-qrcode/tree/v5.0.x) | `^7.4 \|\| ^8.0` | yes | `mbstring` | `gd` or `imagick` required for reading QR Codes, `fileinfo` is used in `QRImagick` | |
  55. | **v4** | [`4.3.4`](https://github.com/chillerlan/php-qrcode/tree/v4.3.x) | `^7.4 \|\| ^8.0` | no | `gd`, `mbstring` | `imagick` | |
  56. | **v3** | [`3.4.1`](https://github.com/chillerlan/php-qrcode/tree/v3.2.x) | `^7.2` | no | `gd`, `mbstring` | `imagick` | v3.4.1 also supports PHP8 |
  57. | **v2** | [`2.0.8`](https://github.com/chillerlan/php-qrcode/tree/v2.0.x) | `>=7.0.3` | no | `gd`, `mbstring` | | |
  58. | **v1** | [`1.0.9`](https://github.com/chillerlan/php-qrcode/tree/v2.0.x-php5) | `>=5.6` | no | `gd`, `mbstring` | | please let PHP 5 die! |
  59. PSA: [PHP versions < 8.0 are EOL](https://www.php.net/supported-versions.php) and therefore the respective `QRCode` versions are also no longer supported!
  60. ## ImageMagick
  61. Please follow the installation guides for your operating system:
  62. - ImageMagick: [imagemagick.org/script/download.php](https://imagemagick.org/script/download.php)
  63. - PHP `ext-imagick`: [github.com/Imagick/imagick](https://github.com/Imagick/imagick) ([Windows downloads](https://mlocati.github.io/articles/php-windows-imagick.html))