PHP Libraries

Codeitnow Barcode & QR Code Generator

Barcode & QR code feature needed in many of web applications. It’s very time taken to write whole code for implementing these features inside their web application. Therefore we have written a PHP package for generating Barcode & QrCode.

This package is easy to use in any PHP Framework or CMS. You can generate different types of barcodes like – Code128, Codabar, Code11, Code39, Code39-Extended, Ean128, Gs1128, I25, Isbn, Msi, Postnet, S25, Upca and Also can generate QrCode for any text.

Installation:

You can install this barcode package using composer in your web application. If you haven’t installed composer on your system then you can download it from https://getcomposer.org/download/

To install CodeItNow Barcode & Qr Code Generator follow below options –

A. If composer is available on command line then run below command


   composer require codeitnowin/barcode
   

B. If composer is not available on command line and you have composer.phar in root location of your web application, then run below command


   php composer.phar require codeitnowin/barcode
   

Uses:

If your applcation has built on Core PHP or CMS. Then you may need to include autoload file manually in your web application.

require_once "Path/to/vendor/autoload.php";

Create a QR Code:

use CodeItNow\BarcodeBundle\Utils\QrCode;

$qrCode = new QrCode();
$qrCode
    ->setText('QR code by codeitnow.in')
    ->setSize(300)
    ->setPadding(10)
    ->setErrorCorrection('high')
    ->setForegroundColor(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0))
    ->setBackgroundColor(array('r' => 255, 'g' => 255, 'b' => 255, 'a' => 0))
    ->setLabel('Scan Qr Code')
    ->setLabelFontSize(16)
    ->setImageType(QrCode::IMAGE_TYPE_PNG)
;
echo '<img src="data:'.$qrCode->getContentType().';base64,'.$qrCode->generate().'" />';

Create a Barcode (Code128):

use CodeItNow\BarcodeBundle\Utils\BarcodeGenerator;

$barcode = new BarcodeGenerator();
$barcode->setText("0123456789");
$barcode->setType(BarcodeGenerator::Code128);
$barcode->setScale(2);
$barcode->setThickness(25);
$barcode->setFontSize(10);
$code = $barcode->generate();

echo '<img src="data:image/png;base64,'.$code.'" />';

Create a Barcode (Codabar):

use CodeItNow\BarcodeBundle\Utils\BarcodeGenerator;

$barcode = new BarcodeGenerator();
$barcode->setText("A0123456789C");
$barcode->setType(BarcodeGenerator::Codabar);
$barcode->setScale(2);
$barcode->setThickness(25);
$barcode->setFontSize(10);
$code = $barcode->generate();

echo '<img src="data:image/png;base64,'.$code.'" />';

Create a Barcode (Code39):

use CodeItNow\BarcodeBundle\Utils\BarcodeGenerator;

$barcode = new BarcodeGenerator();
$barcode->setText("0123456789");
$barcode->setType(BarcodeGenerator::Code39);
$barcode->setScale(2);
$barcode->setThickness(25);
$barcode->setFontSize(10);
$code = $barcode->generate();

echo '<img src="data:image/png;base64,'.$code.'" />';

Create a Barcode (Code39-Extended):

use CodeItNow\BarcodeBundle\Utils\BarcodeGenerator;

$barcode = new BarcodeGenerator();
$barcode->setText("0123456789");
$barcode->setType(BarcodeGenerator::Code39Extended);
$barcode->setScale(2);
$barcode->setThickness(25);
$barcode->setFontSize(10);
$code = $barcode->generate();

echo '<img src="data:image/png;base64,'.$code.'" />';

Create a Barcode (Ean128):

use CodeItNow\BarcodeBundle\Utils\BarcodeGenerator;

$barcode = new BarcodeGenerator();
$barcode->setText("00123456789012345675");
$barcode->setType(BarcodeGenerator::Ean128);
$barcode->setScale(2);
$barcode->setThickness(25);
$barcode->setFontSize(10);
$code = $barcode->generate();

echo '<img src="data:image/png;base64,'.$code.'" />';

Create a Barcode (Gs1128):

use CodeItNow\BarcodeBundle\Utils\BarcodeGenerator;

$barcode = new BarcodeGenerator();
$barcode->setText("00123456789012345675");
$barcode->setType(BarcodeGenerator::Gs1128);
$barcode->setScale(2);
$barcode->setThickness(25);
$barcode->setFontSize(10);
$code = $barcode->generate();

echo '<img src="data:image/png;base64,'.$code.'" />';

Create a Barcode (I25):

use CodeItNow\BarcodeBundle\Utils\BarcodeGenerator;

$barcode = new BarcodeGenerator();
$barcode->setText("00123456789012345675");
$barcode->setType(BarcodeGenerator::I25);
$barcode->setScale(2);
$barcode->setThickness(25);
$barcode->setFontSize(10);
$code = $barcode->generate();

echo '<img src="data:image/png;base64,'.$code.'" />';

Create a Barcode (Isbn):

use CodeItNow\BarcodeBundle\Utils\BarcodeGenerator;

$barcode = new BarcodeGenerator();
$barcode->setText("0012345678901");
$barcode->setType(BarcodeGenerator::Isbn);
$barcode->setScale(2);
$barcode->setThickness(25);
$barcode->setFontSize(10);
$code = $barcode->generate();

echo '<img src="data:image/png;base64,'.$code.'" />';

Create a Barcode (Msi):

use CodeItNow\BarcodeBundle\Utils\BarcodeGenerator;

$barcode = new BarcodeGenerator();
$barcode->setText("0012345678901");
$barcode->setType(BarcodeGenerator::Msi);
$barcode->setScale(2);
$barcode->setThickness(25);
$barcode->setFontSize(10);
$code = $barcode->generate();

echo '<img src="data:image/png;base64,'.$code.'" />';

Create a Barcode (Postnet):

use CodeItNow\BarcodeBundle\Utils\BarcodeGenerator;

$barcode = new BarcodeGenerator();
$barcode->setText("01234567890");
$barcode->setType(BarcodeGenerator::Postnet);
$barcode->setScale(2);
$barcode->setThickness(25);
$barcode->setFontSize(10);
$code = $barcode->generate();

echo '<img src="data:image/png;base64,'.$code.'" />';

Create a Barcode (S25):

use CodeItNow\BarcodeBundle\Utils\BarcodeGenerator;

$barcode = new BarcodeGenerator();
$barcode->setText("012345678901");
$barcode->setType(BarcodeGenerator::S25);
$barcode->setScale(2);
$barcode->setThickness(25);
$barcode->setFontSize(10);
$code = $barcode->generate();

echo '<img src="data:image/png;base64,'.$code.'" />';

Create a Barcode (Upca):

use CodeItNow\BarcodeBundle\Utils\BarcodeGenerator;

$barcode = new BarcodeGenerator();
$barcode->setText("012345678901");
$barcode->setType(BarcodeGenerator::Upca);
$barcode->setScale(2);
$barcode->setThickness(25);
$barcode->setFontSize(10);
$code = $barcode->generate();

echo '<img src="data:image/png;base64,'.$code.'" />';

Change font color and barcode color:

$barcode->setForegroundColor("#FF0000");

Change background color:

$barcode->setBackgroundColor("#FFFFFF");

2 thoughts on “Codeitnow Barcode & QR Code Generator

Leave a Reply

Your email address will not be published. Required fields are marked *