PHP code example of bitgrave / barcode-bundle

1. Go to this page and download the library: Download bitgrave/barcode-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bitgrave / barcode-bundle example snippets


    $ php composer.phar update bitgrave/barcode-bundle

      // app/AppKernel.php
      public function registerBundles()
      {
          return array(
              // ...
              new BG\BarcodeBundle\BarcodeBundle(),
              // ...
          );
      }

 /**
  * simple cache path returning method (sample cache path: "upload/barcode/cache" )
  *
  * @param bool $public
  *
  * @return string
  *
  */
 protected function getBarcodeCachePath($public = false)
 {

     return (!$public) ? $this->get('kernel')->getRootDir(). '/../web/upload/barcode/cache' : '/upload/barcode/cache';
 }

 $this->render('AcmeDemoBundle:Demo:barcode.html.twig', array(
     'barcodePathAndFile' => $this->getBarcodeCachePath($bcPathAbs),
     'barcodeHTML' => $bcHTMLRaw,
 ));

 // AcmeDemoBundle:Demo:barcode.html.twig
 // ...
 <!-- barcode as image -->
 <img src="{{ barcodePathAndFile }}" alt="barcode" title="my barcode image">
 // ...
 <!-- barcode as table -->
 {{ barcodeHTML|raw }}
 // ...