Download the PHP package acelaya/zf2-acqrcode without Composer
On this page you can find all versions of the php package acelaya/zf2-acqrcode. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package zf2-acqrcode
ZF-AcQrCode
This Zend Framework module allows you to easily generate QR codes by using the Endroid QR Code library, by Endroid.
It has been based on the EndroidQrCodeBundle Symfony bundle.
Installation
The preferred installation method is by using composer. Just require this package with composer
and update your dependencies with composer php composer.phar update
After that you just need to add the module to the list of enabled modules in you application.config.php
file
Usage
The module can be used in many ways. It includes a route which points to a controller which returns the QR code image as a response.
You can simply use that route to create your own QR codes by passing four simple arguments. The message to be encoded, the extension of the image (jpeg, png or gif), the size of the image and the padding.
In your view template do something like this.
By default the extension is jpeg, the size is 200 and the padding is 10. The message has to be provided.
Default values can be customized by copying the file vendor/acelaya/zf2-acqrcode/config/qr_code.global.php.dist
to config/autoload/qr_code.global.php
and replacing any of the params defined there.
The view helper
To ease that task, a view helper is provided. By using it you can directly render img tags pointing to that QR code or just get the assembled route just like you would do with the url
view helper.
All the methods in this view helper get the 4 params in the same order; the message, the extension, the size and finally the padding.
This will produce this image
If you need additional attributes in the img tag, if the last argument is an array, it will be treated as the attributes and their values.
This will produce this image:
You can also render a base64-encoded image, instead of using an internal route. This is very useful when you need to render URLs, which is one of the most common use cases.
This will produce this image:
In both cases, if your application is XHTML, the image tag will be automatically closed with />
. If it is HTML5 it will be closed with just >
If you just need to get the route, this view helper is a shortcut to the url
view helper when used like this.
If you need additional route options to be used, it can be done like this.
The service
If that view helper does not fit your needs, or you need to do something else with the QR codes, like saving them to some storage system, you can directly use the QrCodeService
.
It has been registered with the key Acelaya\QrCode\Service\QrCodeService
in order for you to inject it to any of your own services.
The returned object is a Acelaya\QrCode\Service\QrCodeService
which implements Acelaya\QrCode\Service\QrCodeServiceInterface
.
The getQrCodeContent
method accepts the four params in the same order ($message
, $extension
, $size
, $padding
), being the first, the only mandatory argument.
Additionally you can pass a Zend\Controller\Plugin\Params
object as the first param, in order to get the information from route params, ignoring the rest of the arguments passed.
Testing
This module includes all its unit tests and follows dependency injection and abstraction for you to be able to test any component that depend on its classes.
All versions of zf2-acqrcode with dependencies
endroid/qrcode Version ^1.6
zendframework/zend-mvc Version ^3.0
zendframework/zend-router Version ^3.0
zendframework/zend-servicemanager Version ^3.0
zendframework/zend-view Version ^2.8
zendframework/zend-modulemanager Version ^2.7
zendframework/zend-http Version ^2.6
zendframework/zend-eventmanager Version ^3.0
zendframework/zend-stdlib Version ^3.0