Skip to content

Commit ddd9ef0

Browse files
committed
:octocat:
1 parent 16534f6 commit ddd9ef0

File tree

1 file changed

+73
-58
lines changed

1 file changed

+73
-58
lines changed

README.md

Lines changed: 73 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
# chillerlan/php-qrcode
22

3-
A PHP QR Code generator based on the [implementation by Kazuhiko Arase](https://github.com/kazuhikoarase/qrcode-generator),
4-
namespaced, cleaned up, improved and other stuff. It also features a QR Code reader based on a [PHP port](https://github.com/khanamiryan/php-qrcode-detector-decoder) of the [ZXing library](https://github.com/zxing/zxing).
5-
63
**Hi! Please check out the [v5.0-beta release](https://github.com/chillerlan/php-qrcode/releases/tag/5.0-beta) and leave your feedback in [this discussion thread](https://github.com/chillerlan/php-qrcode/discussions/188). Thanks!**
74

8-
**Attention:** there is now also a javascript port: [chillerlan/js-qrcode](https://github.com/chillerlan/js-qrcode).
9-
105
[![PHP Version Support][php-badge]][php]
116
[![Packagist version][packagist-badge]][packagist]
127
[![Continuous Integration][gh-action-badge]][gh-action]
@@ -27,15 +22,26 @@ namespaced, cleaned up, improved and other stuff. It also features a QR Code rea
2722
[downloads-badge]: https://img.shields.io/packagist/dt/chillerlan/php-qrcode?logo=packagist
2823
[downloads]: https://packagist.org/packages/chillerlan/php-qrcode/stats
2924

30-
## Features
25+
26+
## Overview
27+
28+
A PHP QR Code generator based on the [implementation by Kazuhiko Arase](https://github.com/kazuhikoarase/qrcode-generator), namespaced, cleaned up, improved and other stuff. <br>
29+
It also features a QR Code reader based on a [PHP port](https://github.com/khanamiryan/php-qrcode-detector-decoder) of the [ZXing library](https://github.com/zxing/zxing).
30+
31+
32+
**Attention:** there is now also a javascript port: [chillerlan/js-qrcode](https://github.com/chillerlan/js-qrcode).
33+
34+
### Features
3135

3236
- Creation of [Model 2 QR Codes](https://www.qrcode.com/en/codes/model12.html), [Version 1 to 40](https://www.qrcode.com/en/about/version.html)
3337
- [ECC Levels](https://www.qrcode.com/en/about/error_correction.html) L/M/Q/H supported
3438
- Mixed mode support (encoding modes can be combined within a QR symbol). Supported modes:
3539
- numeric
3640
- alphanumeric
3741
- 8-bit binary
38-
- 13-bit double-byte kanji (Japanese, Shift-JIS) and hanzi (simplified Chinese, GB2312/GB18030) as [defined in GBT18284-2000](https://www.chinesestandard.net/PDF/English.aspx/GBT18284-2000)
42+
- 13-bit double-byte:
43+
- kanji (Japanese, Shift-JIS)
44+
- hanzi (simplified Chinese, GB2312/GB18030) as [defined in GBT18284-2000](https://www.chinesestandard.net/PDF/English.aspx/GBT18284-2000)
3945
- Flexible, easily extensible output modules, built-in support for the following output formats:
4046
- [GdImage](https://www.php.net/manual/book.image)
4147
- [ImageMagick](https://www.php.net/manual/book.imagick)
@@ -45,13 +51,9 @@ namespaced, cleaned up, improved and other stuff. It also features a QR Code rea
4551
- PDF via [FPDF](https://github.com/setasign/fpdf)
4652
- QR Code reader (via GD and ImageMagick)
4753

48-
## Documentation
49-
50-
See [the wiki](https://github.com/chillerlan/php-qrcode/wiki) for advanced documentation.
51-
An API documentation created with [phpDocumentor](https://www.phpdoc.org/) can be found at https://chillerlan.github.io/php-qrcode/ (WIP).
52-
The documentation for `QROptions` container can be found here: [chillerlan/php-settings-container](https://github.com/chillerlan/php-settings-container#readme).
5354

5455
### Requirements
56+
5557
- PHP 7.4+
5658
- [`ext-mbstring`](https://www.php.net/manual/book.mbstring.php)
5759
- optional:
@@ -62,14 +64,28 @@ The documentation for `QROptions` container can be found here: [chillerlan/php-s
6264

6365
For the QRCode reader, either `ext-gd` or `ext-imagick` is required!
6466

65-
### Installation
66-
**requires [composer](https://getcomposer.org)**
6767

68-
via terminal:
68+
## Documentation
69+
70+
- The user manual is at https://php-qrcode.readthedocs.io/ ([sources](https://github.com/chillerlan/php-qrcode/tree/main/docs))
71+
- An API documentation created with [phpDocumentor](https://www.phpdoc.org/) can be found at https://chillerlan.github.io/php-qrcode/
72+
- The documentation for `QROptions` container can be found here: [chillerlan/php-settings-container](https://github.com/chillerlan/php-settings-container#readme)
73+
74+
75+
## Installation with [composer](https://getcomposer.org)
76+
77+
See [the installation guide](https://php-qrcode.readthedocs.io/en/main/Usage-Installation.html) for more info!
78+
79+
80+
### Terminal
81+
6982
```
7083
composer require chillerlan/php-qrcode
7184
```
72-
via `composer.json`:
85+
86+
87+
### composer.json
88+
7389
```json
7490
{
7591
"require": {
@@ -78,76 +94,75 @@ via `composer.json`:
7894
}
7995
}
8096
```
97+
8198
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.
82-
See [the installation guide on the wiki](https://github.com/chillerlan/php-qrcode/wiki/Installation) for more info!
8399

84-
### Quickstart
100+
101+
## Quickstart
102+
85103
We want to encode this URI for a mobile authenticator into a QRcode image:
104+
86105
```php
87106
$data = 'otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&issuer=chillerlan.net';
88107

89108
// quick and simple:
90109
echo '<img src="'.(new QRCode)->render($data).'" alt="QR Code" />';
91110
```
111+
112+
Wait, what was that? Please again, slower! See [Advanced usage](https://php-qrcode.readthedocs.io/en/main/Usage-Advanced-usage.html) in the manual.
113+
Also, have a look [in the examples folder](https://github.com/chillerlan/php-qrcode/tree/main/examples) for some more usage examples.
114+
92115
<p align="center">
93116
<img alt="QR codes are awesome!" style="width: auto; height: 530px;" src="https://raw.githubusercontent.com/chillerlan/php-qrcode/main/.github/images/example.svg">
94117
</p>
95118

96-
Wait, what was that? Please again, slower! See [Advanced usage](https://github.com/chillerlan/php-qrcode/wiki/Advanced-usage) on the wiki.
97-
Also, have a look [in the examples folder](https://github.com/chillerlan/php-qrcode/tree/main/examples) for some more usage examples.
98119

99120
### Reading QR Codes
100121

101122
Using the built-in QR Code reader is pretty straight-forward:
123+
102124
```php
103-
$result = (new QRCode)->readFromFile('path/to/file.png'); // -> DecoderResult
125+
// it's generally a good idea to wrap the reader in a try/catch block because it WILL throw eventually
126+
try{
127+
$result = (new QRCode)->readFromFile('path/to/file.png'); // -> DecoderResult
104128

105-
// you can now use the result instance...
106-
$content = $result->data;
107-
$matrix = $result->getMatrix(); // -> QRMatrix
129+
// you can now use the result instance...
130+
$content = $result->data;
131+
$matrix = $result->getMatrix(); // -> QRMatrix
108132

109-
// ...or simply cast it to string to get the content:
110-
$content = (string)$result;
133+
// ...or simply cast it to string to get the content:
134+
$content = (string)$result;
135+
}
136+
catch(Throwable $e){
137+
// oopsies!
138+
}
111139
```
112-
It's generally a good idea to wrap the reading in a try/catch block to handle any errors that may occur in the process.
113-
114-
### Framework Integration
115-
- Drupal:
116-
- [Two-factor Authentication `tfa`](https://www.drupal.org/project/tfa) (Drupal 8+)
117-
- [Google Authenticator Login `ga_login`](https://www.drupal.org/project/ga_login) (deprecated, Drupal 7)
118-
- Symfony
119-
- [phpqrcode-bundle](https://github.com/jonasarts/phpqrcode-bundle)
120-
- WordPress:
121-
- [wp-two-factor-auth](https://github.com/sjinks/wp-two-factor-auth)
122-
- [simple-2fa](https://wordpress.org/plugins/simple-2fa/)
123-
- [floating-share-button](https://github.com/qriouslad/floating-share-button)
124-
- WoltLab Suite
125-
- [two-step-verification](http://pluginstore.woltlab.com/file/3007-two-step-verification/)
126-
- other uses:
127-
- [dependents](https://github.com/chillerlan/php-qrcode/network/dependents) / [packages](https://github.com/chillerlan/php-qrcode/network/dependents?dependent_type=PACKAGE)
128-
- [Appwrite](https://github.com/appwrite/appwrite)
129-
- [Cachet](https://github.com/CachetHQ/Cachet)
130-
- [GÉANT CAT](https://github.com/GEANT/CAT)
131-
- [openITCOCKPIT](https://github.com/it-novum/openITCOCKPIT)
132-
- [twill](https://github.com/area17/twill)
133-
- [Elefant CMS](https://github.com/jbroadway/elefant)
134-
- Articles:
135-
- https://www.twilio.com/blog/create-qr-code-in-php (featuring v4.3.x)
136-
137-
### Shameless advertising
138-
Hi, please check out my other projects that are way cooler than qrcodes!
139140

140-
- [php-oauth-core](https://github.com/chillerlan/php-oauth-core) - an OAuth 1/2 client library along with a bunch of [providers](https://github.com/chillerlan/php-oauth-providers)
141+
142+
## Shameless advertising
143+
144+
Hi, please check out some of my other projects that are way cooler than qrcodes!
145+
146+
- [js-qrcode](https://github.com/chillerlan/js-qrcode) - a javascript port of this library
147+
- [php-authenticator](https://github.com/chillerlan/php-authenticator) - a Google Authenticator implementation (see [authenticator example](https://github.com/chillerlan/php-qrcode/blob/main/examples/authenticator.php))
141148
- [php-httpinterface](https://github.com/chillerlan/php-httpinterface) - a PSR-7/15/17/18 implemetation
149+
- [php-oauth-core](https://github.com/chillerlan/php-oauth-core) - an OAuth 1/2 client library along with a bunch of [providers](https://github.com/chillerlan/php-oauth-providers)
142150
- [php-database](https://github.com/chillerlan/php-database) - a database client & querybuilder for MySQL, Postgres, SQLite, MSSQL, Firebird
151+
- [php-tootbot](https://github.com/php-tootbot/tootbot-template) - a Mastodon bot library (see [@dwil](https://github.com/php-tootbot/dwil))
152+
153+
154+
## Disclaimer!
143155

144-
### Disclaimer!
145156
I don't take responsibility for molten CPUs, misled applications, failed log-ins etc.. Use at your own risk!
146157

147-
#### License notice
148-
Parts of this code are [ported to PHP](https://github.com/codemasher/php-qrcode-decoder) from the [ZXing project](https://github.com/zxing/zxing) and licensed under the [Apache License, Version 2.0](./NOTICE).
149158

150-
#### Trademark Notice
159+
### License notice
160+
161+
- Parts of this code are [ported to PHP](https://github.com/codemasher/php-qrcode-decoder) from the [ZXing project](https://github.com/zxing/zxing) and licensed under the [Apache License, Version 2.0](./NOTICE).
162+
- [The documentation](https://github.com/chillerlan/php-qrcode/tree/main/docs) is licensed under the [Creative Commons Attribution 4.0 International (CC BY 4.0) License](https://creativecommons.org/licenses/by/4.0/).
163+
164+
165+
### Trademark Notice
151166

152167
The word "QR Code" is a registered trademark of *DENSO WAVE INCORPORATED*<br>
153168
https://www.qrcode.com/en/faq.html#patentH2Title

0 commit comments

Comments
 (0)