PHP code example of mapo-89 / laravel-qr-decoder

1. Go to this page and download the library: Download mapo-89/laravel-qr-decoder 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/ */

    

mapo-89 / laravel-qr-decoder example snippets


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' => ['ath('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]);
}

public function decode(QrDecoder $decoder)
{
    return $decoder->decode($path);
}

return [
    'python_path' => base_path('python/qr-decoder'),
    'timeout' => 10,
];
bash
php artisan vendor:publish --tag=config
bash
php artisan qr-decoder:install

laravel-qr-decoder/
├── src/
│   ├── QrDecoder.php
│   ├── QrDecoderFacade.php
│   └── QrDecoderServiceProvider.php
│
├── python/
│   ├── decode_qr.py
│   ├──