endroid / qr-code

QR Code Generator
https://endroid.nl
MIT License
4.45k stars 726 forks source link

Call to undefined method Endroid\QrCode\Builder\Builder::create() #457

Closed Saad-Ramzan-Kiani closed 3 weeks ago

Saad-Ramzan-Kiani commented 3 weeks ago

I'm trying to make Qr Code of links provided by user,

Method: if (isset($validatedData['Permit_link'])) {

            $qrCodeImage = Builder::create()
                ->writer(new PngWriter())
                ->data($validatedData['Permit_link'])
                ->size(300)
                ->build();

                $fileName = 'QrCode_' . time() . '.png';
                $directory = 'uploads/qrcode_images';

            Storage::disk('public')->put($directory . '/' . $fileName, $qrCodeImage->getString());

            $validatedData['Permit_qr_link'] = $directory . '/' . $fileName;
        }

its working perfectly on localhost but on liver server, its displaying me this error: "Internal Server Error: Call to undefined method Endroid\QrCode\Builder\Builder::create() "

endroid commented 3 weeks ago

Hi @Saad-Ramzan-Kiani what version are you using to the composer.lock file on your server?

Saad-Ramzan-Kiani commented 3 weeks ago

"require": { "php": "^8.2", "endroid/qr-code": "^5.0.7",

endroid commented 3 weeks ago

@Saad-Ramzan-Kiani this is the requirement, what does your lock file say? Also, please look at the Builder.php file on the server and let me know what it shows.

Saad-Ramzan-Kiani commented 3 weeks ago

my composer.lock file: ""name": "endroid/qr-code", "version": "5.0.7", "source": { "type": "git", "url": "https://github.com/endroid/qr-code.git", "reference": "0cc00f0626b73bc71a1ea17af01387d0ac75e046" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/endroid/qr-code/zipball/0cc00f0626b73bc71a1ea17af01387d0ac75e046", "reference": "0cc00f0626b73bc71a1ea17af01387d0ac75e046", "shasum": "" }, "require": { "bacon/bacon-qr-code": "^2.0.5", "php": "^8.1" }, "conflict": { "khanamiryan/qrcode-detector-decoder": "^1.0.6" }, "require-dev": { "endroid/quality": "dev-main", "ext-gd": "*", "khanamiryan/qrcode-detector-decoder": "^1.0.4||^2.0.2", "setasign/fpdf": "^1.8.2" }, "suggest": { "ext-gd": "Enables you to write PNG images", "khanamiryan/qrcode-detector-decoder": "Enables you to use the image validator", "roave/security-advisories": "Makes sure package versions with known security issues are not installed", "setasign/fpdf": "Enables you to use the PDF writer" }, "type": "library", "extra": { "branch-alias": { "dev-main": "5.x-dev" } }, "autoload": { "psr-4": { "Endroid\QrCode\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Jeroen van den Enden", "email": "info@endroid.nl" } ], "description": "Endroid QR Code", "homepage": "https://github.com/endroid/qr-code", "keywords": [ "code", "endroid", "php", "qr", "qrcode" ], "support": { "issues": "https://github.com/endroid/qr-code/issues", "source": "https://github.com/endroid/qr-code/tree/5.0.7" }, "funding": [ { "url": "https://github.com/endroid", "type": "github" } ], "time": "2024-03-08T11:24:40+00:00" },"

endroid commented 3 weeks ago

Your lock looks fine, that version should have the create method

https://github.com/endroid/qr-code/blob/0cc00f0626b73bc71a1ea17af01387d0ac75e046/src/Builder/Builder.php#L72

In other words, the remote server seems to have a different version than the one according to your lock file. Please check what methods your live server's Builder.php.

Make sure to check on the live server, not locally of course ;)

Saad-Ramzan-Kiani commented 3 weeks ago

For version: 6.0.0, what method is used in place of create() to generate a new QR code?

endroid commented 3 weeks ago

In 6.x you can simply use the constructor, see https://github.com/endroid/qr-code/blob/master/README.md

Saad-Ramzan-Kiani commented 3 weeks ago

to update to latest version :"endroid/qr-code": "^6.0.1", code: " composer update endroid/qr-code --with-all-dependencies "

Please mention it in README.md file.

Saad-Ramzan-Kiani commented 3 weeks ago

I updated to the latest version, then revised my method, and now it's working perfectly.

endroid commented 3 weeks ago

Hi @Saad-Ramzan-Kiani good to see you found the cause, good luck!