GithubHelp home page GithubHelp logo

lurkeratthegate / barcodebundle Goto Github PK

View Code? Open in Web Editor NEW

This project forked from usemarkup/barcodebundle

0.0 1.0 0.0 16 KB

A Symfony2 bundle that provides straightforward barcode generation using the Zend Barcode component.

License: MIT License

PHP 100.00%

barcodebundle's Introduction

MarkupBarcodeBundle

Build Status

About

This Symfony2 bundle provides a means of generating barcodes using the Zend barcode component and printing them inline using a data URI. It avoids problems with parts of the Zend component that retain state and so allows isolated barcode generation in the same execution cycle.

Installation

Add MarkupBarcodeBundle to your composer.json:

{
    "require": {
        "markup/barcode-bundle": "@dev"
    }
}

Add MarkupBarcodeBundle to your AppKernel.php:

    public function registerBundles()
    {
        $bundles = array(
            ...
            new Markup\BarcodeBundle\MarkupBarcodeBundle(),
        );
        ...
    }

Finally, install the bundle using Composer:

$ php composer.phar update markup/barcode-bundle

Usage

The bundle works by allowing the declaration of named barcode definitions (specifying the spec being used for the barcode, the output format, etc). These definitions are then referred to when rendering an individual barcode.

Say you had a barcode you needed to generate for an "invoice" in your application. This invoice uses barcodes that were Code 128, and you want to use PNG as the image format for the barcode (PNG is, incidentally, the default).

You can achieve this by declaring the definition in the bundle's semantic configuration:

    markup_barcode:
        definitions:
            invoice:
                type: code128
                format: png

Alternatively, if you need more flexibility, you can write your own definition class that implements Markup\BarcodeBundle\Definition\DefinitionInterface and declare it as a service within your bundle, using a markup_barcode.definition tag with a declared alias:

    my.barcode_definition:
        class: Me\MyBundle\Barcode\MyInvoiceBarcodeDefinition
        tags:
            - { name: markup_barcode.definition, alias: invoice }

Then, within a Twig template, you would use the following Twig filter (markup_barcode_data_uri) to generate a barcode from the text you are encoding:

    <img src="{{ barcode_text_you_are_encoding|markup_barcode_data_uri('invoice') }}">

License

Released under the MIT License. See LICENSE.

barcodebundle's People

Contributors

shieldo avatar lurkeratthegate avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.