Search by

james2001 / zxing-bundle

james2001

Symfony bundle to read QR codes and barcodes from images with ZXing

Package info

github.com/james2001/zxingbundle

Type:symfony-bundle

pkg:composer/james2001/zxing-bundle

Statistics

Installs: 115

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

3.0.0 2026-12-01 07:46 UTC

This package is auto-updated.

Last update: 2026-12-01 09:28:31 UTC


README

CI Latest Stable Version Total Downloads License

Symfony bundle to read QR codes and barcodes from images, with the james2001/zxing library (a PHP wrapper around the Java ZXing reader).

Which version should I use?

Bundle Branch PHP Symfony Library
3.x 3.x 8.1+ 6.4, 7.x, 8.x james2001/zxing 2.x
2.x 2.x 7.2.5 – 8.x 4.4, 5.4 james2001/zxing 1.x/2.x
1.x 1.x 5.4 – 7.4 2.3 – 3.4 james2001/zxing 1.x

composer require james2001/zxing-bundle installs the newest version compatible with your PHP and Symfony versions.

This branch (3.x) is the active one, for Symfony 6.4, 7.x and 8.x applications.

Requirements

Java 8 or later must be installed on the server: the java command has to be in the PATH.

Installation

composer require james2001/zxing-bundle

With Symfony Flex the bundle is enabled automatically. Otherwise add it to config/bundles.php:

return [
    // ...
    James2001\Bundle\ZxingBundle\James2001ZxingBundle::class => ['all' => true],
];

Configuration

Everything is optional, for instance in config/packages/james2001_zxing.yaml:

james2001_zxing:
    key: ''           # only keep codes containing this key (removed from the result)
    options: []       # extra ZXing options, e.g. ['--try_harder'] (a string such as '--try_harder' works too)
    lib_bin_path: ''  # directory holding the ZXing jars (defaults to the bundled ones)

options is passed to the ZXing command line (without any shell): never fill it with user input. The available options are listed in the james2001/zxing README.

Usage

use James2001\Zxing;

class ScanController extends AbstractController
{
    public function scan(Zxing $zxing): Response
    {
        $first = $zxing->findFirst('/path/image.jpg');  // string, or false if nothing is found
        $all = $zxing->findMulti('/path/image.jpg');    // array of strings, or false

        // ...
    }
}

The reader is also available as the public james2001.zxing service.

Upgrading from 2.x

  • PHP 8.1 and Symfony 6.4 are the new minimums, and james2001/zxing 2.x is required: it ships ZXing 3.5, which needs Java 8 and spells some options differently (--possible_formats QR_CODE instead of --possibleFormats=QR_CODE). See its upgrade notes.
  • options can now be a list; a string is split on spaces.
  • The bundle class is now an AbstractBundle and is final: the DependencyInjection classes are gone. The james2001_zxing configuration key, the james2001.zxing service and the Zxing autowiring alias don't change.

Upgrading from 1.x

Apply these changes, then the ones of "Upgrading from 2.x" above:

  • The james2001_zxing.key, james2001_zxing.options, james2001_zxing.libBinPath and james2001_zxing.class parameters are replaced by the james2001_zxing configuration key shown above (libBinPath becomes lib_bin_path).
  • The sources moved to src/ and Resources/config/services.yml is gone: the service is declared by the extension. The service id james2001.zxing doesn't change.

Tests

composer install
vendor/bin/phpunit

License

MIT, see LICENSE.