PHP code example of devoton / qrcode
1. Go to this page and download the library: Download devoton/qrcode 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/ */
devoton / qrcode example snippets
use DevOton\QrCode\Contracts\QrCodeGeneratorInterface;
$generator = app(QrCodeGeneratorInterface::class);
$svg = $generator->svg('https://example.com');
use DevOton\QrCode\Facades\DevOtonQrCode;
$png = DevOtonQrCode::png('https://example.com', [
'size' => 180,
'margin' => 2,
'foreground' => '#111827',
'background' => '#ffffff',
'error_correction' => 'medium',
]);
use DevOton\QrCode\Contracts\QrCodeGeneratorInterface;
$svg = app(QrCodeGeneratorInterface::class)
->make('https://example.com')
->size(220)
->margin(3)
->foreground('#0f172a')
->background('#ffffff')
->errorCorrection('quartile')
->encoding('UTF-8')
->asSvg();
$svg = $generator->svg('https://example.com', 160, 2);
$png = $generator->png('https://example.com', [
'size' => 160,
'margin' => 2,
]);
$dataUri = $generator->dataUri('https://example.com', [
'format' => 'svg',
]);
$generator->save('https://example.com', storage_path('app/qrcode.svg'));
return [
'default_size' => 150,
'default_margin' => 1,
'encoding' => 'UTF-8',
'default_error_correction' => 'low',
'default_foreground' => '#000000',
'default_background' => '#ffffff',
];
bash
php artisan vendor:publish --tag=devoton-qrcode-config
bash
vendor/bin/pint --dirty --format agent
php artisan test --compact packages/devoton/qrcode/tests/Feature/DevOtonQrCodePackageTest.php packages/devoton/qrcode/tests/Unit/DevOtonQrCodeNativeFoundationTest.php packages/devoton/qrcode/tests/Unit/DevOtonQrCodeNativePipelineTest.php packages/devoton/qrcode/tests/Unit/DevOtonQrCodeConformanceTest.php packages/devoton/qrcode/tests/Unit/DevOtonQrCodeCodewordSnapshotTest.php packages/devoton/qrcode/tests/Unit/DevOtonQrCodeIntermediateSnapshotTest.php