You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
In simple Qr-code plugin for Laravel "You need to install ImageMagick" bug #112
I have installed the simplesoftwareio / simple-qrcode plugin. It worked fine in PHP 5.4 but we are trying to upgrade.
Now when I upgrade and try to use the code to generate the QR code, we get this error.
"You need to install the imagick extension to use this backend".
~/src/Renderer/Image/ImagickImageBackEnd.php:64
But imagick IS INSTALLED. I found many other people with this same problem (so I'm not crazy here) and they all resolved in downgrading to BaconQrCode version 1.0.3. But Laravel 8 won't let me do that, because of requirements.
So I'm just stuck and wondering if this can be fixed?
I was never able to reproduce that issue on any of my systems, nor on the CI servers. So unless you can figure out what causes that error, I can't really do anything about it.
As a workaround, I'd recommend to use the SVG backend instead.
OK I think I might have solved the problem, "FOR LARAVEL"... and it's really silly if this is the case.
It might be possible that after installing the PHP package "php-imagick", it still doesn't work on the Laravel instance. BECAUSE, you have to restart the Laravel server to acknowledge the new PHP package. When you start Laravel it makes a unique container for the site, and it doesn't get updated with the new plugins until restart.
And I saw dozens of people (and on person here within hours of posting this) who all experienced this same problem. So you might want to keep this in mind, or keep this thread available for search, or maybe even add it notes in your documentation for us Laravel users.
With above knowledge. I have it working now. It worked on PHP7.4 and PHP8.0 on my dev server.
Now to onto figure out why Imagick fails to install on production server.
I was also thinking it would be nice if you gave us quick code tip on how to use SVG instead of Imagick backend.
Anyway, thanks for your quick response. I really appreciate it.
Glad that you figured it out! That you need to restart PHP after installing an extension is kinda general knowledge and far outside the scope of any PHP library :).
As for an example, instead of using the ImagickImageBackend class, you can simply use the SvgImageBackend class, that's a simple swap.
Sorry, NOT to restart PHP, I know that. It's particular to Laravel. You have to RESTART LARAVEL if you are working in the Laravel container. "php artisan serve". Perhaps you don't use Laravel, so I just wanted to clarify that. This entire issue was specific to the Laravel plugin so I wanted to make sure that's clear for Laravel users. I highly suspect this is why many people are experiencing this. I read MANY cases of it.
I assume that restarting the Laravel container is equivalent to restarting the PHP instance it is using. Anyway, this should rather be in the Laravel documentation.
I'm using Laravel and never faced this issue. But I installed "bacon/bacon-qr-code" directly. And I'm using Apache+PHP locally, not Laravel container. So that issue with Imagick might be documented somewhere else.
However, my client is using really stupid web-hosting. They had issues with Imagick 2 years ago, and it is not fixed till now. So I'm working on GD driver. Will create PR later, might be handy for others too.
Yes, I can use SVG backend, but not always. I'm sending QR code payment in email, and email clients have issues with SVG.
Activity
aghasemiN commentedon Jul 19, 2022
well I have the same problem here
DASPRiD commentedon Jul 19, 2022
I was never able to reproduce that issue on any of my systems, nor on the CI servers. So unless you can figure out what causes that error, I can't really do anything about it.
As a workaround, I'd recommend to use the SVG backend instead.
b-art-xx commentedon Jul 19, 2022
OK I think I might have solved the problem, "FOR LARAVEL"... and it's really silly if this is the case.
It might be possible that after installing the PHP package "php-imagick", it still doesn't work on the Laravel instance. BECAUSE, you have to restart the Laravel server to acknowledge the new PHP package. When you start Laravel it makes a unique container for the site, and it doesn't get updated with the new plugins until restart.
And I saw dozens of people (and on person here within hours of posting this) who all experienced this same problem. So you might want to keep this in mind, or keep this thread available for search, or maybe even add it notes in your documentation for us Laravel users.
With above knowledge. I have it working now. It worked on PHP7.4 and PHP8.0 on my dev server.
Now to onto figure out why Imagick fails to install on production server.
I was also thinking it would be nice if you gave us quick code tip on how to use SVG instead of Imagick backend.
Anyway, thanks for your quick response. I really appreciate it.
DASPRiD commentedon Jul 19, 2022
Glad that you figured it out! That you need to restart PHP after installing an extension is kinda general knowledge and far outside the scope of any PHP library :).
As for an example, instead of using the
ImagickImageBackendclass, you can simply use theSvgImageBackendclass, that's a simple swap.b-art-xx commentedon Jul 19, 2022
Sorry, NOT to restart PHP, I know that. It's particular to Laravel. You have to RESTART LARAVEL if you are working in the Laravel container. "php artisan serve". Perhaps you don't use Laravel, so I just wanted to clarify that. This entire issue was specific to the Laravel plugin so I wanted to make sure that's clear for Laravel users. I highly suspect this is why many people are experiencing this. I read MANY cases of it.
DASPRiD commentedon Jul 19, 2022
I assume that restarting the Laravel container is equivalent to restarting the PHP instance it is using. Anyway, this should rather be in the Laravel documentation.
arxeiss commentedon Jul 20, 2022
I'm using Laravel and never faced this issue. But I installed
"bacon/bacon-qr-code"directly. And I'm using Apache+PHP locally, not Laravel container. So that issue with Imagick might be documented somewhere else.However, my client is using really stupid web-hosting. They had issues with Imagick 2 years ago, and it is not fixed till now. So I'm working on GD driver. Will create PR later, might be handy for others too.
Yes, I can use SVG backend, but not always. I'm sending QR code payment in email, and email clients have issues with SVG.