Developed with love by KnpLabs Hire us for your project!
68

EndroidQrCodeBundle

by endroid

QR Code Generation Bundle for use in Symfony

Endroid QR Code Bundle

By endroid

Latest Stable Version
Build Status
Latest Stable Version
Total Downloads
License
PayPayl donate button

This bundle provides a default controller for generating QR codes using the
Endroid QR Code (endroid/QrCode) library.

knpbundles.com

Requirements

  • Symfony
  • Dependencies:

Installation

Use Composer to install the bundle.

$ composer require endroid/qrcode-bundle

Then enable the bundle via the kernel.

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Endroid\Bundle\QrCodeBundle\EndroidQrCodeBundle(),
    );
}

Routing

Add the following section to your routing to be able to handle QR code URLs.
This step can be skipped when you only use data URIs to display your images.

EndroidQrCodeBundle:
    resource:   "@EndroidQrCodeBundle/Controller/"
    type:       annotation
    prefix:     /qrcode

Configuration

The default QR code generation parameters can be overridden via the
configuration. All parameters are optional.

config.yml

endroid_qr_code:
    size: 100
    padding: 10
    extension: gif
    error_correction_level: high
    foreground_color: { r: 0, g: 0, b: 0, a: 0 }
    background_color: { r: 255, g: 255, b: 255, a: 0 }
    label: "My label"
    labelFontSize: 16

Alpha channel available range is [0, 127] in foreground and background colors.

Twig extension

The bundle also provides a Twig extension for quickly generating QR code urls.
Optional parameters are extension, size, padding and errorCorrectionLevel. When
a parameter is omitted, the value in the bundle configuration is used.

<img src="{{ qrcode_url(message) }}" />
<img src="{{ qrcode_url(message, extension='png') }}" />
<img src="{{ qrcode_url(message, size=150) }}" />

You can also use the data URI helper to embed the QR code within your HTML
instead of requiring a separate HTTP request to load your image.

<img src="{{ qrcode_data_uri(message, size=200, padding=10) }}" />

Usage

After installation and configuration, QR codes can be generated by appending
the QR code text to the url as mounted, followed by .png, .jpg or .gif.

QR Code

Versioning

Semantic versioning (semver) is applied.

License

This bundle is under the MIT license. For the full copyright and license information, please view the LICENSE file that
was distributed with this source code.

Copyright (c) 2014 Jeroen van den Enden

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
  • Update installation instructions
    By endroid, 1 year ago
  • Merge pull request #19 from davidromani/develop
    By endroid, 2 years ago
  • add alpha channel documentation
    By davidromani, 2 years ago
  • Run php-cs-fixer
    By endroid, 2 years ago
  • Add support for label
    By endroid, 2 years ago
  • Remove empty parameter array
    By endroid, 2 years ago
  • Add new configuration parameters to readme
    By endroid, 2 years ago
  • Add colors to configuration and some refactoring
    By endroid, 2 years ago
  • Merge pull request #14 from kategray/master
    By endroid, 2 years ago
  • Add validator to dev dependencies
    By jerend, 2 years ago
  • Fix error correction
    By , 2 years ago
  • Add note on versioning
    By endroid, 2 years ago
  • Add error correction level parameter to config
    By endroid, 2 years ago
  • Update badges
    By endroid, 2 years ago
  • Update badges
    By endroid, 2 years ago
  • Merge pull request #11 from Nyholm/patch-1
    By endroid, 2 years ago
  • Added more PHP versions and HHVM
    By Nyholm, 2 years ago
  • Merge pull request #10 from imanzuk/master
    By endroid, 2 years ago
  • Update QrCodeExtension.php
    By imanzuk, 2 years ago
  • Minor change
    By endroid, 2 years ago
  • Add Twig helper for generating a data URI
    By endroid, 2 years ago
  • Make bundle defaults configurable
    By endroid, 2 years ago
  • Change padding to correspond to default padding
    By endroid, 2 years ago
  • Merge pull request #9 from cryshell/add_padding_option
    By endroid, 2 years ago
  • Added option to set the padding via Twig
    By Jörg Wolfgram, 2 years ago
  • Add required expression language component
    By endroid, 2 years ago
  • Update dependencies
    By endroid, 2 years ago
  • Move size parameter back to query string
    By endroid, 2 years ago
  • Use generated route in test to ensure correctness
    By endroid, 2 years ago
  • Cleaner size handling
    By endroid, 2 years ago