PHPackages                             ofcold/qrcode - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ofcold/qrcode

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ofcold/qrcode
=============

An easy-to-use PHP QrCode generator.

1.0.2(7y ago)101183PHPPHP ^7.2

Since Feb 12Pushed 6y ago1 watchersCompare

[ Source](https://github.com/ofcold/qr-code)[ Packagist](https://packagist.org/packages/ofcold/qrcode)[ Docs](https://ofcold.com)[ RSS](/packages/ofcold-qrcode/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (3)Dependencies (4)Versions (5)Used By (0)

 [![](https://github.com/ofcold/qr-code/raw/master/qr.png)](https://github.com/ofcold/qr-code/raw/master/qr.png)

Ofcold QR code

An easy-to-use PHP QrCode generator.

[简体中文文档](https://github.com/ofcold/qr-code/blob/master/README_zh-CN.md)

Introduction
------------

[](#introduction)

> Simple QrCode is an easy to use wrapper for the popular Laravel framework based on the great work provided by [Bacon/BaconQrCode](https://github.com/Bacon/BaconQrCode). We created an interface that is familiar and easy to install for Laravel users.

[Example](https://github.com/ofcold/laravel-qr-code-test)

Installation
------------

[](#installation)

```
composer require ofcold/qrcode
```

Usage
-----

[](#usage)

> Heads up! This method must be called last if using within a chain.

Generate by default will return a SVG image string. You can print this directly into a modern browser within Laravel's Blade system with the following:

```
QrCode::generate($text);

// The generate method has a second parameter that will accept a filename and path to save the QrCode.
QrCode::generate($text, 'public/qrcode.svg');
```

### Basic

[](#basic)

```
use Ofcold\QrCode\Facades\QrCode;
use Ofcold\QrCode\HexToRgb;

$text = 'Happy New Year';

// Default output svg format file.
QrCode::generate($text);
```

### Response

[](#response)

> The browser directly outputs the image.

#### use `QRcodeResponse`

[](#use-qrcoderesponse)

```
use Ofcold\QrCode\QRcodeResponse

new QRcodeResponse(QrCode::generate($text))
```

#### use `response()`

[](#use-response)

```
$qr = QrCode::color('#ff0000');

response($qr->generate($text))->header('Content-Type', $qr->getContentType())
```

### Format Change

[](#format-change)

> QrCode Generator is setup to return a SVG image by default. Watch out! The format method must be called before any other formatting options such as size, color, backgroundColor, and margin.

```
// Output other file formats.
QrCode::format('png')
	->generate($text);
```

### Size Change

[](#size-change)

> QrCode Generator will by default return the smallest size possible in pixels to create the QrCode.

```
// You can change the size of a QrCode by using the size method. Simply specify the size desired in pixels using the following syntax:
QrCode::size(400)
	->generate($text);
```

### Color Change

[](#color-change)

> Be careful when changing the color of a QrCode. Some readers have a very difficult time reading QrCodes in color.

```
// Change the QR code color, Supported rgb and hex
// All colors must be expressed in RGB (Red Green Blue). You can change the color of a QrCode by using the following: 255.255.0 OR #ff0000
QrCode::color(HexToRgb::make('#ff0000'))
	// color([255, 0, 0])
	->format('png')
	->generate($text);

```

### Margin Change

[](#margin-change)

> The ability to change the margin around a QrCode is also supported. Simply specify the desired margin using the following syntax:

```
QrCode::margin(100)->generate($text);
```

### Error Correction

[](#error-correction)

> Changing the level of error correction is easy. Just use the following syntax: L = 1 M = 0 Q = 3 H = 1

```
QrCode::errorCorrection(1)->generate($text);
```

### Encoding

[](#encoding)

> Change the character encoding that is used to build a QrCode. By default ISO-8859-1 is selected as the encoder. Read more about character encoding You can change this to any of the following:

```
QrCode::encoding('UTF-8')->generate($text);
```

Character Encoder: ISO-8859-1, ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-8859-10, ISO-8859-11, ISO-8859-12, ISO-8859-13, ISO-8859-14, ISO-8859-15, ISO-8859-16, SHIFT-JIS, WINDOWS-1250, WINDOWS-1251, WINDOWS-1252, WINDOWS-1256, UTF-16BE, UTF-8, ASCII, GBK, EUC-KR,

> An error of Could not encode content to ISO-8859-1 means that the wrong character encoding type is being used. We recommend UTF-8 if you are unsure.

### Merge

[](#merge)

> The merge method merges an image over a QrCode. This is commonly used to placed logos within a QrCode.

```
QrCode::merge($filename, $percentage, $absolute);

// Generates a QrCode with an image centered in the middle.
QrCode::format('png')->merge('path-to-image.png')->generate();

// Generates a QrCode with an image centered in the middle.  The inserted image takes up 20% of the QrCode.
QrCode::format('png')->merge('path-to-image.png', .2)->generate();

// Generates a QrCode with an image centered in the middle.  The inserted image takes up 20% of the QrCode.
QrCode::format('png')->merge('http://ofcold.com/icon.png', .2, true)->generate();
```

> The merge method only supports PNG at this time. The filepath is relative to app base path if $absolute is set to false. Change this variable to true to use absolute paths. You should use a high level of error correction when using the merge method to ensure that the QrCode is still readable. We recommend using errorCorrection(1).

### Merge Binary String

[](#merge-binary-string)

> The mergeString method can be used to achieve the same as the merge call, except it allows you to provide a string representation of the file instead of the filepath. This is usefull when working with the Storage facade. It's interface is quite similar to the merge call.

```
QrCode::mergeString(Storage::get('path/to/image.png'), $percentage);

// Generates a QrCode with an image centered in the middle.
QrCode::format('png')->mergeString(Storage::get('path/to/image.png'))->generate();

// Generates a QrCode with an image centered in the middle.  The inserted image takes up 20% of the QrCode.
QrCode::format('png')->mergeString(Storage::get('path/to/image.png'), .2)->generate();
```

> As with the normal merge call, only PNG is supported at this time. The same applies for error correction, high levels are recommened.

### Advance Usage

[](#advance-usage)

All methods support chaining. The `generate` method must be called last and any format change must be called first. For example you could run any of the following:

```
QrCode::size(250)->color(150,90,10)->backgroundColor(10,14,244)->generate($text);
QrCode::format('png')->size(399)->color(40,40,40)->generate($text);
```

Helpers
-------

[](#helpers)

### What are helpers?

[](#what-are-helpers)

Helpers are an easy way to create QrCodes that cause a reader to perform a certain action when scanned.

### BitCoin

[](#bitcoin)

This helpers generates a scannable bitcoin to send payments. [More information](https://bitco.in/en/developer-guide#plain-text)

```
QrCode::BTC($address, $amount);

//Sends a 0.334BTC payment to the address
QrCode::BTC('bitcoin address', 0.334);

// Sends a 0.334BTC payment to the address with some optional arguments
QrCode::size(500)->BTC('address', 0.0034, [
	'label' => 'my label',
	'message' => 'my message',
	'returnAddress' => 'https://www.returnaddress.com'
]);
```

### E-Mail

[](#e-mail)

This helper generates an e-mail qrcode that is able to fill in the e-mail address, subject, and body.

```
QrCode::email($to, $subject, $body);

// Fills in the to address
QrCode::email('foo@bar.com');

// Fills in the to address, subject, and body of an e-mail.
QrCode::email('foo@bar.com', 'This is the subject.', 'This is the message body.');

// Fills in just the subject and body of an e-mail.
QrCode::email(null, 'This is the subject.', 'This is the message body.');
```

### Geo

[](#geo)

This helper generates a latitude and longitude that a phone can read and open the location up in Google Maps or similar app.

```
QrCode::geo($latitude, $longitude);

QrCode::geo(37.822214, -122.481769);
```

### Phone Number

[](#phone-number)

This helper generates a QrCode that can be scanned and then dials a number.

```
QrCode::phoneNumber($phoneNumber);

QrCode::phoneNumber('18898726543');
QrCode::phoneNumber('1-800-MY-APPLE');
```

### SMS (Text Messages)

[](#sms-text-messages)

This helper makes SMS messages that can be prefilled with the send to address and body of the message.

```
QrCode::SMS($phoneNumber, $message);

// Creates a text message with the number filled in.
QrCode::SMS('555-555-5555');

// Creates a text message with the number and message filled in.
QrCode::SMS('555-555-5555', 'Body of the message');
```

### Wi-Fi

[](#wi-fi)

This helpers makes scannable QrCodes that can connect a phone to a WiFI network.

```
QrCode::wiFi([
	'encryption' => 'WPA/WEP',
	'ssid' => 'SSID of the network',
	'password' => 'Password of the network',
	'hidden' => 'Whether the network is a hidden SSID or not.'
]);

// Connects to an open WiFi network.
QrCode::wiFi([
	'ssid' => 'Network Name',
]);

// Connects to an open, hidden WiFi network.
QrCode::wiFi([
	'ssid' => 'Network Name',
	'hidden' => 'true'
]);

// Connects to an secured, WiFi network.
QrCode::wiFi([
	'ssid' => 'Network Name',
	'encryption' => 'WPA',
	'password' => 'myPassword'
]);
```

License
-------

[](#license)

This software is released under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~9 days

Total

3

Last Release

2630d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c52a844b37ff37e8fa6d7bf4b482d8ff4ef15e250098d1f60bd19041d953834?d=identicon)[billwithjiali](/maintainers/billwithjiali)

---

Top Contributors

[![lilianjin](https://avatars.githubusercontent.com/u/21023027?v=4)](https://github.com/lilianjin "lilianjin (34 commits)")

### Embed Badge

![Health badge](/badges/ofcold-qrcode/health.svg)

```
[![Health](https://phpackages.com/badges/ofcold-qrcode/health.svg)](https://phpackages.com/packages/ofcold-qrcode)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[watson/active

Laravel helper for recognising the current route, controller and action

3253.6M14](/packages/watson-active)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[dragon-code/pretty-routes

Pretty Routes for Laravel

10058.7k4](/packages/dragon-code-pretty-routes)[beyondcode/laravel-favicon

Create dynamic favicons based on your environment settings.

37345.5k](/packages/beyondcode-laravel-favicon)[bjuppa/laravel-blog

Add blog functionality to your Laravel project

483.3k2](/packages/bjuppa-laravel-blog)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
