akira/laravel-qrcode

A clean, modern, and easy-to-use QR code generator for Laravel

Fund package maintenance!
kidiatoliny

Installs: 5

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 0

Forks: 1

Open Issues: 0

pkg:composer/akira/laravel-qrcode

1.x-dev 2025-11-10 23:49 UTC

This package is auto-updated.

Last update: 2025-11-10 23:49:21 UTC


README

img.png

Latest Version on Packagist Tests PHPStan Total Downloads

A clean, modern, and easy-to-use QR code generator for Laravel applications. Built with the Action Pattern, Value Objects, and full type safety.

Features

  • Multiple output formats (PNG, SVG, EPS)
  • Highly customizable (colors, gradients, styles, sizes)
  • Specialized data types (WiFi, Email, Phone, SMS, Geo, Bitcoin)
  • Logo/image merging support
  • Type-safe with PHP 8.4+
  • PHPStan Level 9 compliant
  • Comprehensive test coverage

Requirements

  • PHP 8.4+
  • Laravel 12.0+

Installation

Install via Composer:

composer require akira/laravel-qrcode

Optionally, publish the configuration:

php artisan vendor:publish --tag="qrcode-config"

Quick Start

use Akira\QrCode\Facades\QrCode;

// Simple text
$qrCode = QrCode::text('Hello World');

// With customization
$qrCode = QrCode::size(300)
    ->color(255, 0, 0)
    ->text('https://example.com');

// WiFi network
$qrCode = QrCode::wifi([
    'ssid' => 'MyNetwork',
    'password' => 'secret123'
]);

// Email
$qrCode = QrCode::email('contact@example.com', 'Subject', 'Body');

// Phone
$qrCode = QrCode::phone('+1234567890');

// With styling
$qrCode = QrCode::size(400)
    ->gradient(255, 0, 0, 0, 0, 255, 'diagonal')
    ->style('round', 0.7)
    ->eye('circle')
    ->text('Styled QR Code');

Documentation

Complete documentation is available in the docs folder:

Getting Started

  1. Installation - Detailed installation guide
  2. Configuration - Configuration options
  3. Quick Start - Get started in 5 minutes

Usage Guide

  1. Basic Usage - Fundamentals and examples
  2. Data Types - WiFi, Email, Phone, SMS, Geo, Bitcoin
  3. Customization - Colors, gradients, styles
  4. Advanced Features - Logo merging, custom types

Examples & Reference

  1. Examples - Real-world use cases
  2. Architecture - Package design patterns
  3. API Reference - Complete method reference
  4. Testing - Testing guide
  5. Contributing - How to contribute

Available Data Types

Type Description Example
WiFi Network credentials QrCode::wifi(['ssid' => 'Network', 'password' => 'pass'])
Email mailto links QrCode::email('email@example.com', 'Subject', 'Body')
Phone Direct dial QrCode::phone('+1234567890')
SMS Pre-filled message QrCode::sms('+1234567890', 'Hello')
Geo GPS coordinates QrCode::geo(37.7749, -122.4194, 'San Francisco')
Bitcoin Payment address QrCode::bitcoin('address', 0.001, ['label' => 'Donation'])

Customization Options

Option Description Values
Size Dimensions in pixels size(300)
Colors Foreground/background color(r, g, b), backgroundColor(r, g, b)
Gradients Color transitions gradient(r1, g1, b1, r2, g2, b2, 'type')
Styles Module shapes style('square|dot|round', 0-1)
Eyes Pattern styles eye('square|circle'), eyeColor(...)
Error Correction Data recovery errorCorrection('L|M|Q|H')
Formats Output type format('png|svg|eps')
Logo Image merging merge('/path/to/logo.png', 0.2)

Usage Examples

In Blade Templates

<img src="data:image/png;base64,{{ base64_encode($qrCode) }}" alt="QR Code">

API Response

return response()->json([
    'qrcode' => base64_encode(QrCode::format('png')->text($data))
]);

Download Response

$png = QrCode::format('png')->size(500)->text($data);

return response($png)
    ->header('Content-Type', 'image/png')
    ->header('Content-Disposition', 'attachment; filename="qrcode.png"');

With Logo

$qrCode = QrCode::format('png')
    ->size(400)
    ->errorCorrection('H')
    ->merge(public_path('logo.png'), 0.2)
    ->text('https://example.com');

Testing

# Run tests
composer test

# Run tests with coverage
composer test-coverage

# Run static analysis
composer analyse

# Run code style fixer
composer lint

Architecture

This package is built with:

  • Action Pattern - Single-responsibility business logic
  • Value Objects - Immutable, validated data structures
  • Dependency Injection - Laravel IoC container
  • Type Safety - PHP 8.4+ with readonly classes
  • SOLID Principles - Clean, maintainable code

See Architecture Documentation for details.

Contributing

Contributions are welcome! Please see Contributing Guide for details.

Security

If you discover any security issues, please email kidiatoliny@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Links