PHPackages                             dsiddharth2/php-zxing - 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. dsiddharth2/php-zxing

ActiveLibrary

dsiddharth2/php-zxing
=====================

Wrapper for zxing using php

1.0.3(6y ago)136270.8k—5.5%23[5 issues](https://github.com/dsiddharth2/php-zxing/issues)[2 PRs](https://github.com/dsiddharth2/php-zxing/pulls)2MITPHP

Since Dec 25Pushed 3y ago6 watchersCompare

[ Source](https://github.com/dsiddharth2/php-zxing)[ Packagist](https://packagist.org/packages/dsiddharth2/php-zxing)[ RSS](/packages/dsiddharth2-php-zxing/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)DependenciesVersions (6)Used By (2)

PHPZxing - Wrapper for Zxing Java Library
=========================================

[](#phpzxing---wrapper-for-zxing-java-library)

PHPZxing is a small php wrapper that uses the Zxing library to Create and read Barcodes. Under the hood it still uses the [Zxing library](https://github.com/zxing/zxing) to encode and decode data.

Install using composer
----------------------

[](#install-using-composer)

```
{
    "require": {
        "dsiddharth2/php-zxing": "1.0.3"
    }
}
```

Note
----

[](#note)

- Only Decoder is programmed right now. Needs programming of Encoder.
- The Default location of java that is configured is /usr/bin/java

Changes in version 1.0.3
------------------------

[](#changes-in-version-103)

- Functionality added for possible\_formats to work

Changes in version 1.0.2
------------------------

[](#changes-in-version-102)

- Updated the new jars and tested on windows system

Changes in version 1.0.1
------------------------

[](#changes-in-version-101)

- Added a isFound function that will tell if the bar code is found.
- If the image has one bar code detected, then it returns the object instead of array of a single object.

Basic Usage
-----------

[](#basic-usage)

```
use PHPZxing\PHPZxingDecoder;

$decoder        = new PHPZxingDecoder();
$data           = $decoder->decode('../images/Code128Barcode.jpg');
if($data->isFound()) {
    $data->getImageValue();
    $data->getFormat();
    $data->getType();
}
```

The Decoded data is an Array of Objects of PHPZxing\\ZxingImage if the bar code is found. If not found then it is an array of Objects PHPZxing\\ZxingBarNotFound.

Checking for existence of Barcode
---------------------------------

[](#checking-for-existence-of-barcode)

The Existance of bar code can be found using the functoin isFound()

```
use PHPZxing\PHPZxingDecoder;

$decoder        = new PHPZxingDecoder();
$data           = $decoder->decode('../images/Code128Barcode.jpg');
if($data->isFound()) {
    $data->getImageValue();
    $data->getFormat();
    $data->getType();
}
```

You can also check using the instanceof object,

```
use PHPZxing\PHPZxingDecoder;

$decoder        = new PHPZxingDecoder();
$data           = $decoder->decode('../images/Code128Barcode.jpg');
if($data instanceof PHPZxing\ZxingImage) {
    $data->getImageValue();
    $data->getFormat();
    $data->getType();
}
```

The Public methods that we can use in PHPZxing\\ZxingImage are,

Method NameFunctiongetImageValueGet the value decoded in the image passedgetFormatGet the format of the image that is encoded, example : CODE\_39getTypeGet the type of the image decoded, example : URL, TEXT etcgetImagePathGet Path of the imageThe Public methods that we can use in PHPZxing\\ZxingImage are,

Method NameFunctiongetImageErrorCodeGet the error code for the image not foundgetErrorMessageError MessagegetImagePathGet Path of the imageSetting the configurations
--------------------------

[](#setting-the-configurations)

```
use PHPZxing\PHPZxingDecoder;

$config = array(
    'try_harder'            => true,
);
$decoder        = new PHPZxingDecoder($config);
$decodedArray   = $decoder->decode('../images');
if(is_array($decodedArray)){
    foreach ($decodedArray as $data) {
        if($data->isFound()) {
            print_r($data);
        }
    }
}
```

You can also use it with configurations. The Decoder has 4 configurations,

Config NameFunctiontry\_harderIf the image has bar/Qr code at unknown locations, then use this non mobile mode.multiple\_bar\_codesIf the image has multiple bar codes you want to read.cropCrop the image and it will read only the cropped portionpossible\_formatsList of formats to decode, where format is any value in BarcodeFormatMore Examples
-------------

[](#more-examples)

You can pass array of images too,

```
use PHPZxing\PHPZxingDecoder;

$decoder        = new PHPZxingDecoder();
$imageArrays = array(
    '../images/Code128Barcode.jpg',
    '../images/Code39Barcode.jpg'
);
$decodedArray  = $decoder->decode($imageArrays);
foreach ($decodedArray as $data) {
    if($data instanceof PHPZxing\ZxingImage) {
        print_r($data);
    } else {
        echo "Bar Code cannot be read";
    }
}
```

Reading multiple bar codes,

```
use PHPZxing\PHPZxingDecoder;

$config = array(
    'try_harder' => true,
    'multiple_bar_codes' => true
);
$decoder        = new PHPZxingDecoder($config);
$decodedData    = $decoder->decode('../images/multiple_bar_codes.jpg');
print_r($decodedData);
```

Set Java Path
-------------

[](#set-java-path)

If your java PATH is not set properly, the decoder will not work. You need to set path of java variable.

```
use PHPZxing\PHPZxingDecoder;

$decoder        = new PHPZxingDecoder();
$decoder->setJavaPath('/your/path/to/java');
$decodedData    = $decoder->decode('../images/Code128Barcode.jpg');
print_r($decodedData);
```

Where is my java located ?
--------------------------

[](#where-is-my-java-located-)

If you do not know the path to java, then you can use the following on \*nix enviromnents

```
$ which java

```

On Windows environment,

```
> where java

```

For more info, on Windows read the follwoing stackoverflow [Link](https://stackoverflow.com/questions/304319/is-there-an-equivalent-of-which-on-the-windows-command-line)

Acknowledgments
---------------

[](#acknowledgments)

- [Zxing library](https://github.com/zxing/zxing)

Contibution
-----------

[](#contibution)

Please Contribute or suggest changes.

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity51

Moderate usage in the ecosystem

Community24

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% 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 ~204 days

Total

4

Last Release

2453d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/89de07268d6cd508bef0dee2e1857382c836d855798809e74db75877fa1d3808?d=identicon)[dsiddharth2](/maintainers/dsiddharth2)

---

Top Contributors

[![dsiddharth2](https://avatars.githubusercontent.com/u/6525909?v=4)](https://github.com/dsiddharth2 "dsiddharth2 (12 commits)")[![sidAtApra](https://avatars.githubusercontent.com/u/119999790?v=4)](https://github.com/sidAtApra "sidAtApra (3 commits)")[![alb3ric](https://avatars.githubusercontent.com/u/5337626?v=4)](https://github.com/alb3ric "alb3ric (1 commits)")[![matrad](https://avatars.githubusercontent.com/u/660903?v=4)](https://github.com/matrad "matrad (1 commits)")[![sid-mildlyclassic](https://avatars.githubusercontent.com/u/19463811?v=4)](https://github.com/sid-mildlyclassic "sid-mildlyclassic (1 commits)")

---

Tags

decoderzxing-library

### Embed Badge

![Health badge](/badges/dsiddharth2-php-zxing/health.svg)

```
[![Health](https://phpackages.com/badges/dsiddharth2-php-zxing/health.svg)](https://phpackages.com/packages/dsiddharth2-php-zxing)
```

PHPackages © 2026

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