acharsoft/zbar-qrdecoder

PHP对Zbar的包装。解码包含QR码的图像/照片。

2.0.2 2016-03-13 16:05 UTC

This package is auto-updated.

Last update: 2024-09-11 22:54:00 UTC


README

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

这是对zbar-tools的PHP包装 - 目前仅支持zbarimg。请参阅http://zbar.sourceforge.net/

要求

  • zbar-tools - 在Ubuntu上安装,只需sudo apt-get install zbar-tools。请参阅他们的项目页面了解更多平台。
  • ImageMagick - Zbar需要它,我不确定它们是否打包提供,所以请确保您有它。

安装

通过Composer安装此软件包。

将此添加到您的composer.json依赖项

"require": {
   "robbiep/zbar-qrdecoder": "^2.0"
}

运行composer install以下载所需的文件。

使用方法

require_once('vendor/autoload.php');

$ZbarDecoder = new RobbieP\ZbarQrdecoder\ZbarDecoder();

# Optionally change the path of the zbarimg executable if you need to (default: /usr/bin)
$ZbarDecoder->setPath('/usr/local/bin');

# Decode the image
$result = $ZbarDecoder->make('/a/path/to/image_with_barcode.jpg');

echo $result; // Outputs the decoded text
echo $result->format; // Outputs the barcode's format
echo $result->code; // 200 if it decoded a barcode OR 400 if it couldn't find a barcode.

如果您正在使用Laravel...

如果您需要更改任何选项,我已包括一个ServiceProvider类和配置文件。您需要将ServiceProvider添加到config/app.php

'providers' => array(
    ...
    'RobbieP\ZbarQrdecoder\ZbarQrdecoderServiceProvider'
)

您可能需要发布配置php artisan vendor:publish

现在您可以在Laravel应用程序中使用Zbar QR解码器了!

使用方法(在Laravel中)

# Decode the image
$result = ZbarDecoder::make('/a/path/to/image_with_barcode.png');

echo $result; // Outputs the decoded text
echo $result->format; // Outputs the barcode's format

其他支持的条码

  • EAN_13 / ISBN
  • CODE_39
  • CODE_128

贡献

  1. 分支
  2. 创建您的功能分支:git checkout -b my-new-feature
  3. 提交您的更改:git commit -am '添加一些功能'
  4. 推送到分支:git push origin my-new-feature
  5. 提交一个pull请求