A cross‑platform Laravel package for decoding QR codes from PNG images using Python
mapo-89/laravel-qr-decoder is a Laravel package for a cross‑platform laravel package for decoding qr codes from png images using python.
It currently has 1 GitHub stars and 2 downloads on Packagist (latest version v1.1.1).
Install it with composer require mapo-89/laravel-qr-decoder.
Discover more Laravel packages by mapo-89
or browse all Laravel packages to compare alternatives.
Last updated
A cross‑platform Laravel package for decoding QR codes from PNG images using Python (zxing-cpp).
This package wraps a Python decoder inside a virtual environment and exposes a clean Laravel API. It works on Windows and Linux using OS‑specific wrapper scripts.
venv// composer.json
{
"repositories": [
{
"type": "path",
"url": "packages/laravel-qr-decoder"
}
]
}
composer require mapo-89/laravel-qr-decoder
php artisan vendor:publish --tag=config
Edit config/qr-decoder.php:
return [
'python_path' => base_path('python/qr-decoder'),
'timeout' => 10,
];
php artisan qr-decoder:install
This command will:
This package does not provide controllers or views.
It exposes a single service (QrDecoder) that can be used inside your application’s controllers, APIs, jobs or commands.
use Mapo89\QrDecoder\QrDecoder;
$result = app(QrDecoder::class)->decode(
storage_path('app/qr_uploaded_file.png')
);
public function uploadAndDecode(Request $request, QrDecoder $decoder)
{
$request->validate([
'qrpng' => ['required', 'file', 'mimes:png', 'max:5120'],
]);
// Store temporarily
$path = $request->file('qrpng')->store('qr-decoder');
$fullPath = storage_path('app/private/' . $path);
try {
$result = $decoder->decode($fullPath);
} catch (\Throwable $e) {
$result = null;
// Handle error if needed
} finally {
if (file_exists($fullPath)) {
@unlink($fullPath);
}
}
return response()->json(['result' => $result]);
}
Note: The controller should live in your application, not in this package. If you need a UI, build it in your application or in a separate package that depends on this one.
public function decode(QrDecoder $decoder)
{
return $decoder->decode($path);
}
return [
'python_path' => base_path('python/qr-decoder'),
'timeout' => 10,
];
laravel-qr-decoder/
├── src/
│ ├── QrDecoder.php
│ ├── QrDecoderFacade.php
│ └── QrDecoderServiceProvider.php
│
├── python/
│ ├── decode_qr.py
│ ├── requirements.txt
│ ├── run_qr_decoder
│ ├── run_qr_decoder.bat
│ └── venv/
│
├── config/
│ └── qr-decoder.php
│
├── composer.json
└── README.md
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.