PHPackages                             isahaq/barcode - 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. isahaq/barcode

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

isahaq/barcode
==============

A universal barcode generator package supporting multiple barcode types and output formats, with extra features like batch generation, watermarking, validation, CLI, and Laravel Facade support.

v1.0.0(10mo ago)11721MITPHPPHP ^8.0

Since Jul 13Pushed 6mo agoCompare

[ Source](https://github.com/isahaq1/barcodeGeneratorPkg)[ Packagist](https://packagist.org/packages/isahaq/barcode)[ RSS](/packages/isahaq-barcode/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

[![Isahaq Barcode Generator](banner.png)](banner.png)

Isahaq Barcode Generator
========================

[](#isahaq-barcode-generator)

A universal barcode generator package supporting **32+ barcode types** (linear, 2D, postal, stacked, and auto-detection variants), multiple output formats, CLI, and full Laravel integration (Service Provider &amp; Facade).

---

🚀 Features
----------

[](#-features)

- **32+ Barcode Types**: Linear, 2D, postal, stacked, and auto-detection variants
- **Multiple Output Formats**: PNG, SVG, HTML, JPG, PDF
- **Laravel Integration**: Service Provider and Facade support
- **CLI Tool**: Command-line interface for quick barcode generation
- **QR Code Builder**: Fluent API for advanced QR code generation
- **Validation**: Built-in data validation for different barcode types
- **Customization**: Size, colors, margins, and more options

📦 Installation
--------------

[](#-installation)

### Via Composer

[](#via-composer)

```
composer require isahaq/barcode
```

### Requirements

[](#requirements)

- PHP 8.0 or higher
- ext-mbstring extension
- For Laravel: Illuminate/Support 8.0+ (automatically included)

🔧 Why Use This Package?
-----------------------

[](#-why-use-this-package)

1. **Comprehensive Support**: 32+ barcode types including industry standards and auto-detection
2. **Multiple Formats**: Generate barcodes in PNG, SVG, HTML, JPG, and PDF
3. **Laravel Ready**: Seamless integration with Laravel framework
4. **CLI Support**: Generate barcodes from command line
5. **Advanced QR Codes**: Customizable QR codes with logos and labels
6. **Validation**: Built-in data validation for each barcode type
7. **Performance**: Optimized for high-volume generation
8. **Extensible**: Easy to add new barcode types and renderers

⚡ Laravel Setup for Older Versions
----------------------------------

[](#-laravel-setup-for-older-versions)

If you are using an older version of Laravel (before package auto-discovery), add the service provider and facade alias manually in your `config/app.php`:

```
'providers' => [
    // ...
    Isahaq\Barcode\Providers\BarcodeServiceProvider::class,
],

'aliases' => [
    // ...
    'Barcode' => Isahaq\Barcode\Facades\Barcode::class,
],
```

📋 Supported Barcode Types (32+ Types)
-------------------------------------

[](#-supported-barcode-types-32-types)

### Linear Barcodes

[](#linear-barcodes)

- **Code128** (A, B, C, Auto)
- **Code39** (Standard, Checksum, Extended, Auto)
- **Code93**
- **Code25** (Standard, Auto)
- **Code32** (Italian Pharmacode)
- **Standard25** (Standard, Checksum)
- **Interleaved25** (Standard, Checksum, Auto)
- **MSI** (Standard, Checksum, Auto)

### EAN/UPC Family

[](#eanupc-family)

- **EAN13**, **EAN8**, **EAN2**, **EAN5**
- **UPC-A**, **UPC-E**
- **ITF14**

### Postal Barcodes

[](#postal-barcodes)

- **POSTNET**, **PLANET**, **RMS4CC**, **KIX**, **IMB**

### Specialized Barcodes

[](#specialized-barcodes)

- **Codabar**, **Code11**, **PharmaCode**, **PharmaCodeTwoTracks**

### 2D Matrix Codes

[](#2d-matrix-codes)

- **QRCode**, **DataMatrix**, **Aztec**, **PDF417**, **MicroQR**, **Maxicode**

### Stacked Linear Codes

[](#stacked-linear-codes)

- **Code16K**, **Code49**

---

🛠️ Usage
--------

[](#️-usage)

### Basic PHP Usage

[](#basic-php-usage)

```
require_once 'vendor/autoload.php';
use Isahaq\Barcode\Types\Code128;
use Isahaq\Barcode\Renderers\PNGRenderer;
$barcodeType = new Code128();
$renderer = new PNGRenderer();
$barcode = $barcodeType->encode('1234567890');
$result = $renderer->render($barcode);
file_put_contents('barcode.png', $result);
```

### Display Barcode as Base64 Image (PNG)

[](#display-barcode-as-base64-image-png)

```
// ... after generating $barcode (PNG data)
$barcodeImage = base64_encode($barcode);
echo '';
//with custom height width
echo '';
```

### QR Code with Logo and Watermark

[](#qr-code-with-logo-and-watermark)

```
use Isahaq\Barcode\QrCodeBuilder;

$qrCode = QrCodeBuilder::create()
    ->data('https://example.com')
    ->size(300)
    ->margin(10)
    ->foregroundColor([0, 0, 0])
    ->backgroundColor([255, 255, 255])
    ->logoPath('path/to/logo.png') // Logo in the center
    ->label('Scan me!')            // Watermark or label below
    ->labelFont('path/to/font.ttf', 16)
    ->format('png')
    ->build();

// Save to file
$qrCode->saveToFile('qr-code-with-logo.png');

// Display as base64 image
echo '';
```

### Using the Service Class

[](#using-the-service-class)

```
use Isahaq\Barcode\Services\BarcodeService;
$barcodeService = new BarcodeService();
$pngData = $barcodeService->png('1234567890', 'code128');
$svgData = $barcodeService->svg('1234567890', 'ean13');
$htmlData = $barcodeService->html('1234567890', 'code39');
$options = [ 'width' => 300, 'height' => 100 ];
$customBarcode = $barcodeService->make('code128', 'png', '1234567890', $options);
```

### QR Code Builder (Advanced)

[](#qr-code-builder-advanced)

```
use Isahaq\Barcode\QrCodeBuilder;
$qrCode = QrCodeBuilder::create()
    ->data('https://example.com')
    ->size(300)
    ->margin(10)
    ->foregroundColor([0, 0, 0])
    ->backgroundColor([255, 255, 255])
    ->logoPath('path/to/logo.png')
    ->label('Scan me!')
    ->labelFont('path/to/font.ttf', 16)
    ->format('png')
    ->build();
$qrCode->saveToFile('qr-code.png');
$dataUri = $qrCode->getDataUri();
echo "";
```

🎯 Laravel Integration
---------------------

[](#-laravel-integration)

### Using Laravel Facade

[](#using-laravel-facade)

```
use Isahaq\Barcode\Facades\Barcode;
$barcode = Barcode::png('1234567890', 'code128');
$qrCode = Barcode::modernQr([
    'data' => 'https://example.com',
    'size' => 300,
    'margin' => 10,
    'error_correction' => 'H',
    'foreground_color' => [0, 0, 0],
    'background_color' => [255, 255, 255],
    'label' => 'Scan me!'
]);
return response($barcode)->header('Content-Type', 'image/png');
```

### QR Code with Logo (Laravel Facade)

[](#qr-code-with-logo-laravel-facade)

```
use Isahaq\Barcode\Facades\Barcode;
$qrWithLogo = Barcode::modernQr([
    'data' => 'https://example.com',
    'size' => 300,
    'margin' => 10,
    'logoPath' => 'path/to/logo.png',
    'logoSize' => 60, // Logo size as percentage (default: 60)
    'label' => 'Scan me!',
    'error_correction' => 'H' // Use H for better logo support
]);
return response($qrWithLogo)->header('Content-Type', 'image/png');
```

### Available Watermark Positions

[](#available-watermark-positions)

```
$positions = Barcode::getWatermarkPositions();
// Returns: ['top-left', 'top-right', 'bottom-left', 'bottom-right', 'center',
//           'top-center', 'bottom-center', 'left-center', 'right-center']
```

### Using Service Provider

[](#using-service-provider)

```
public function generateBarcode(Request $request)
{
    $barcodeService = app('barcode');
    $data = $request->input('data', '1234567890');
    $type = $request->input('type', 'code128');
    $format = $request->input('format', 'png');
    $options = [ 'width' => $request->input('width', 300), 'height' => $request->input('height', 100) ];
    $barcode = $barcodeService->make($type, $format, $data, $options);
    return response($barcode)->header('Content-Type', $this->getMimeType($format));
}
private function getMimeType($format)
{
    return match($format) {
        'png' => 'image/png',
        'svg' => 'image/svg+xml',
        'html' => 'text/html',
        default => 'image/png'
    };
}
```

### Blade Templates &amp; Routes

[](#blade-templates--routes)

```

//with custom height width

// routes/web.php
Route::get('/barcode/{data}', function ($data) {
    $barcode = Barcode::png($data, 'code128');
    return response($barcode)->header('Content-Type', 'image/png');
});
```

🖥️ CLI Usage
------------

[](#️-cli-usage)

```
php vendor/bin/generate.php --data="1234567890" --type="code128" --format="png" --output="barcode.png"
php vendor/bin/generate.php --data="https://example.com" --type="qrcode" --format="png" --output="qr.png"
php vendor/bin/generate.php --data="1234567890" --type="ean13" --format="svg" --output="barcode.svg"
```

📊 Advanced Features
-------------------

[](#-advanced-features)

- **Batch Generation**
- **Custom Renderer Options**
- **Validation**
- **Auto-detection**: Use `code128auto`, `code39auto`, `code25auto`, `interleaved25auto`, `

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance61

Regular maintenance activity

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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

Unknown

Total

1

Last Release

307d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/11f213329a74dc5367c135ed69a8595ed2fc0709ca0617a99c4e39d342784a54?d=identicon)[isahaq](/maintainers/isahaq)

---

Top Contributors

[![isahaq1](https://avatars.githubusercontent.com/u/28819010?v=4)](https://github.com/isahaq1 "isahaq1 (70 commits)")

---

Tags

phpqrcodelaravelgeneratorbarcode

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/isahaq-barcode/health.svg)

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

###  Alternatives

[linkxtr/laravel-qrcode

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

295.1k](/packages/linkxtr-laravel-qrcode)[akira/laravel-qrcode

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

431.4k](/packages/akira-laravel-qrcode)

PHPackages © 2026

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