1. Go to this page and download the library: Download hennest/qr-code 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/ */
hennest / qr-code example snippets
'providers' => [
// Other Service Providers
Hennest\QRCode\Providers\QRCodeServiceProvider::class,
],
use Hennest\QRCode\Enums\Color;
use Hennest\QRCode\Configuration\Dimension;
use Hennest\QRCode\Configuration\ColorScheme;
use Hennest\QRCode\Services\QRCodeInterface;
class ExampleController
{
public function __construct(
private QRCodeInterface $qrCode
) {}
public function example()
{
// Generate a QR code
$qrCode = $this->qrCode->generate('https://example.com')->toSvg();
// Generate a QR code with custom settings
$qrCode = $this->qrCode->generate(
content: 'https://example.com',
dimension: new Dimension(
size: 300,
margin: 300
),
colorScheme: new ColorScheme(
foreground: Color::Black,
background: Color::White
)
)->toSvg();
// Save a QR code to a file
$this->qrCode->generate('https://example.com')->toImage('path/to/file.svg');
}
public function anotherExample()
{
// Generate a QR code
$qrCode = app(QRCodeInterface::class)->generate('https://example.com')->toSvg();
// Generate a QR code with custom settings
$qrCode = app(QRCodeInterface::class)->generate(
content: 'https://example.com',
dimension: new Dimension(
size: 300,
margin: 300
),
colorScheme: new ColorScheme(
foreground: Color::Black,
background: Color::White
)
)->toSvg();
// Save a QR code to a file
$qrCode = app(QRCodeInterface::class)->generate('https://example.com')->toImage('path/to/file.svg');
}
}
return [
/**
* QR Code assembler configuration
*/
'assembler' => [
/**
* QR Code assembler
*/
'assembler' => Hennest\QRCode\Assembler\QRCodeAssembler::class,
/**
* QR Code assembler disk
*/
'disk' => 'public',
],
/**
* QR Code default encoding
*/
'encoding' => BaconQrCode\Encoder\Encoder::DEFAULT_BYTE_MODE_ECODING,
/**
* QR Code service
*/
'qr-code' => Hennest\QRCode\Services\QRCode::class,
/**
* QR Code renderer configuration
*/
'renderer' => [
/**
* QR Code renderer
*/
'renderer' => BaconQrCode\Renderer\ImageRenderer::class,
/**
* QR Code renderer backend
*/
'backend' => BaconQrCode\Renderer\Image\SvgImageBackEnd::class,
/**
* QR Code renderer default style configuration
*/
'style' => [
/**
* QR Code renderer style
*/
'style' => Hennest\QRCode\Configuration\RenderStyle::class,
/**
* QR Code renderer size
*/
'size' => env('QR_CODE_SIZE', 300),
/**
* QR Code renderer margin
*/
'margin' => env('QR_CODE_MARGIN', 4),
/**
* QR Code renderer color
*/
'color' => [
/**
* QR Code renderer foreground color
*/
'foreground' => Hennest\QRCode\Enums\Color::Black,
/**
* QR Code renderer background color
*/
'background' => Hennest\QRCode\Enums\Color::White,
],
],
],
];
bash
php artisan vendor:publish --tag=qr-code
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.