Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Php Qrcode Laravel Package

chillerlan/php-qrcode

Generate and read QR codes in PHP. Supports Model 2 QR codes (versions 1–40), ECC levels L/M/Q/H, mixed encoding modes, and multiple output formats. Includes a QR code reader based on a PHP port of ZXing.

View on GitHub
Deep Wiki
Context7

QRMarkupXML

Class QRMarkupXML: eXtensible Markup Language (XML) output

Example

See: XML example

Set the options:

$options = new QROptions;

$options->outputInterface  = QRMarkupXML::class;
$options->outputBase64     = false;
// if set to false, the light modules won't be included in the output
$options->drawLightModules = false;

// assign an XSLT stylesheet
$options->xmlStylesheet    = './qrcode.style.xsl';

$options->moduleValues     = [
	QRMatrix::M_FINDER_DARK    => '#A71111', // dark (true)
	QRMatrix::M_FINDER_DOT     => '#A71111', // finder dot, dark (true)
	QRMatrix::M_FINDER         => '#FFBFBF', // light (false)
	QRMatrix::M_ALIGNMENT_DARK => '#A70364',
	QRMatrix::M_ALIGNMENT      => '#FFC9C9',
	QRMatrix::M_VERSION_DARK   => '#650098',
	QRMatrix::M_VERSION        => '#E0B8FF',
];

The XSLT stylesheet qrcode.style.xsl:

<?xml version="1.0" encoding="UTF-8"?>
<!-- XSLT style for the XML output example -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
	<xsl:template match="/">
		<!-- SVG header -->
		<svg xmlns="http://www.w3.org/2000/svg"
		     version="1.0"
		     viewBox="0 0 {qrcode/matrix/[@width](https://github.com/width)} {qrcode/matrix/[@height](https://github.com/height)}"
		     preserveAspectRatio="xMidYMid"
		>
			<!--
				path for a single module
				we could define a path for each layer and use the [@layer](https://github.com/layer) attribute for selection,
				but that would exaggerate this example
			-->
			<symbol id="module" width="1" height="1">
				<circle cx="0.5" cy="0.5" r="0.4" />
			</symbol>
			<!-- loop over the rows -->
			<xsl:for-each select="qrcode/matrix/row">
				<!-- set a variable for $y (vertical) -->
				<xsl:variable name="y" select="[@y](https://github.com/y)"/>
				<xsl:for-each select="module">
					<!-- set a variable for $x (horizontal) -->
					<xsl:variable name="x" select="[@x](https://github.com/x)"/>
					<!-- draw only dark modules -->
					<xsl:if test="[@dark](https://github.com/dark)='true'">
						<!-- position the module and set its fill color -->
						<use href="#module" class="{[@layer](https://github.com/layer)}" x="{$x}" y="{$y}" fill="{[@value](https://github.com/value)}"/>
					</xsl:if>
				</xsl:for-each>
			</xsl:for-each>
		</svg>
	</xsl:template>
</xsl:stylesheet>

Render the output:

$data = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ';
$out  = new QRCode($options)->render($data); // -> XML, rendered as SVG

header('Content-type: application/xml');

echo $out;

The associated XML schema can be found over at GitHub: qrcode.schema.xsd

Additional methods

method return description
(protected) createMatrix() DOMElement creates the matrix element
(protected) row(int $y, array $row) DOMElement|null creates a DOM element for a matrix row
(protected) module(int $x, int $y, int $M_TYPE) DOMElement|null creates a DOM element for a single module

Options that affect this class

property type
$drawLightModules bool
$outputBase64 bool
xmlStylesheet string
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport