Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid method call #462

Closed
cankirca opened this issue Jan 3, 2025 · 1 comment
Closed

Invalid method call #462

cankirca opened this issue Jan 3, 2025 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@cankirca
Copy link

cankirca commented Jan 3, 2025

Hello,

İnstalled QRCode via compoer and using following PHP code to generate, however getting following error:
Fatal error: Uncaught Error: Call to undefined method Endroid\QrCode\Builder\Builder::fromScratch() in /var/www/generate_qr.php:18 Stack trace: #0 {main} thrown in /var/www/generate_qr.php on line 18

Code:

<?php
require 'vendor/autoload.php';

use Endroid\QrCode\Builder\Builder;
use Endroid\QrCode\Encoding\Encoding;
use Endroid\QrCode\ErrorCorrectionLevel;
use Endroid\QrCode\RoundBlockSizeMode;
use Endroid\QrCode\Writer\PngWriter;

if (isset($_GET['id'])) {
    $productId = trim($_GET['id']); // Ürün ID'sini al

    // QR kod oluşturma
    $result = Builder::create()
        ->writer(new PngWriter())
        ->writerOptions([])
        ->data($productId)
        ->encoding(new Encoding('ISO-8859-1')) // Maksimum uyumluluk için ISO-8859-1
        ->errorCorrectionLevel(new ErrorCorrectionLevel(ErrorCorrectionLevel::LOW))
        ->size(200)                             // QR kod boyutu (200 piksel)
        ->margin(10)                            // Kenar boşluğu (10 piksel)
        ->roundBlockSizeMode(new RoundBlockSizeMode(RoundBlockSizeMode::MARGIN))
        ->build();

    // Tarayıcıya PNG çıktısı gönderme
    header('Content-Type: image/png');
    header('Content-Disposition: inline; filename="qr-' . $productId . '.png"');
    echo $result->getString();
    exit;
} else {
    echo "ID not found!";
}
@endroid
Copy link
Owner

endroid commented Jan 4, 2025

Hi @cankirca my code does not provide a fromScratch() method so please look further on your side where it comes from.

@endroid endroid closed this as completed Jan 4, 2025
@endroid endroid self-assigned this Jan 4, 2025
@endroid endroid added the question Further information is requested label Jan 4, 2025
@endroid endroid changed the title Builder error Invalid method call Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants