PHP code example of yellowskies / qr-code-bundle

1. Go to this page and download the library: Download yellowskies/qr-code-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/ */

    

yellowskies / qr-code-bundle example snippets


return [
    // ...
    Skies\QRcodeBundle\SkiesQRcodeBundle::class => ['all' => true],
];

use Skies\QRcodeBundle\Generator\Generator;

class MyController extends AbstractController
{
    public function index(Generator $generator): Response
    {
        $barcode = $generator->generate([
            'code'   => 'Hello World',
            'type'   => 'qrcode',
            'format' => 'svg',
            'width'  => 10,
            'height' => 10,
            'color'  => 'green',
        ]);

        return new Response($barcode);
    }
}

use Skies\QRcodeBundle\Generator\Generator;

$generator = new Generator();
$barcode = $generator->generate([
    'code'   => 'Hello World',
    'type'   => 'qrcode',
    'format' => 'html',
]);

// HTML or SVG
file_put_contents('/tmp/barcode.svg', $barcode);

// PNG (decode base64 first)
file_put_contents('/tmp/barcode.png', base64_decode($barcode));