acharsoft / zbar-qrdecoder
PHP对Zbar的包装。解码包含QR码的图像/照片。
2.0.2
2016-03-13 16:05 UTC
Requires
- php: >=5.5.0
- symfony/process: ^3.0
Requires (Dev)
- mockery/mockery: 0.9.*@dev
- phpunit/phpunit: 4.3.5
README
这是对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
贡献
- 分支
- 创建您的功能分支:
git checkout -b my-new-feature
- 提交您的更改:
git commit -am '添加一些功能'
- 推送到分支:
git push origin my-new-feature
- 提交一个pull请求