Няма описание

smiley 1e6006d9df :fire: PHP 8.5? преди 2 месеца
.github 1e6006d9df :fire: PHP 8.5? преди 2 месеца
.idea d65911ada9 :octocat: dependency update & phpstan happy преди 6 месеца
.phan 2f404ba8ee :octocat: преди 5 месеца
.phpdoc 22869ae8e2 :book: преди 1 година
benchmark e6b1ff0ada :octocat: run phpstan on the benchmarks преди 1 година
docs 5c948cffd4 :book: remove remaining instances of empty() преди 2 месеца
examples 89de3849dd :book: преди 2 месеца
src 02ec24ee07 :shower: преди 2 месеца
tests 2ba2b4ebaa :octocat: phpcs happy преди 2 месеца
.editorconfig 826f9cfa65 :octocat: преди 2 години
.gitattributes 89cdd09044 :octocat: switch phan for phpstan (see #277) преди 1 година
.gitignore 89cdd09044 :octocat: switch phan for phpstan (see #277) преди 1 година
.readthedocs.yml 6a44b067ef :sparkles: fuck it, read the docs преди 2 години
LICENSE-ASL-2.0 66c0b69ffb :octocat: added Apache-2.0 license преди 3 години
LICENSE-MIT 66c0b69ffb :octocat: added Apache-2.0 license преди 3 години
NOTICE ff147426a1 :octocat: moved some files преди 2 години
README.md 9cf399d8c3 :octocat: преди 8 месеца
composer.json 1e6006d9df :fire: PHP 8.5? преди 2 месеца
phpbench.json f31eff72f5 :sparkles: add PHPBench to run benchmarks преди 1 година
phpcs.xml.dist d65911ada9 :octocat: dependency update & phpstan happy преди 6 месеца
phpdoc.xml.dist 61bf95856a :octocat: преди 2 години
phpmd.xml.dist 10ed887663 :octocat: +phpmd command преди 1 година
phpstan-baseline.neon 6a3e93bb3a :octocat: преди 2 месеца
phpstan.dist.neon e6b1ff0ada :octocat: run phpstan on the benchmarks преди 1 година
phpunit.xml.dist f02b94f3e6 :shower: преди 1 година

README.md

chillerlan/php-qrcode

A PHP QR Code generator based on the implementation by Kazuhiko Arase, namespaced, cleaned up, improved and other stuff.
It also features a QR Code reader based on a PHP port of the ZXing library.

Attention: there is now also a javascript port on NPM: @chillerlan/qrcode.

PHP Version Support Packagist version Continuous Integration CodeCov Codacy Packagist downloads Documentation

Overview

Features

  • Creation of Model 2 QR Codes, Version 1 to 40
  • ECC Levels L/M/Q/H supported
  • Mixed mode support (encoding modes can be combined within a QR symbol). Supported modes:
  • Flexible, easily extensible output modules, built-in support for the following output formats:
  • QR Code reader (via GD and ImageMagick)

Requirements

For the QR Code reader, either ext-gd or ext-imagick is required!

Documentation

Important: Please use the examples from the branch that matches your installed php-qrcode version ( v4.x, v5.x, dev-main )!
The main (default) branch is the active development for future major versions, and it is most likely incompatible with the latest release versions.

Installation with composer

See the installation guide for more info!

Terminal

composer require chillerlan/php-qrcode

composer.json

{
	"require": {
		"php": "^8.2",
		"chillerlan/php-qrcode": "dev-main#<commit_hash>"
	}
}

Note: replace dev-main with a version constraint, e.g. ^5.0 - see releases for valid versions.

Quickstart

We want to encode this URI for a mobile authenticator into a QRcode image:

$data = 'otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&issuer=chillerlan.net';

// quick and simple:
echo '<img src="'.(new QRCode)->render($data).'" alt="QR Code" />';

Wait, what was that? Please again, slower! See Advanced usage in the manual. Also, have a look in the examples folder for some more usage examples.

QR codes are awesome!

Reading QR Codes

Using the built-in QR Code reader is pretty straight-forward:

// it's generally a good idea to wrap the reader in a try/catch block because it WILL throw eventually
try{
	$result = (new QRCode)->readFromFile('path/to/file.png'); // -> DecoderResult

	// you can now use the result instance...
	$content = $result->data;
	$matrix  = $result->getMatrix(); // -> QRMatrix

	// ...or simply cast it to string to get the content:
	$content = (string)$result;
}
catch(Throwable $e){
	// oopsies!
}

Shameless advertising

Hi, please check out some of my other projects that are way cooler than qrcodes!

Disclaimer!

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

License notice

Trademark Notice

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