Skip to content

In simple Qr-code plugin for Laravel "You need to install ImageMagick" bug #112

Description

@b-art-xx

For Laravel 8, running PHP 7.4 or PHP 8.

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?

Screenshot 2022-07-19 123529

Activity

  1. aghasemiN commented on Jul 19, 2022

    @aghasemiN

    well I have the same problem here

  2. DASPRiD commented on Jul 19, 2022

    @DASPRiD
    Member

    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.

  3. b-art-xx commented on Jul 19, 2022

    @b-art-xx
    Author

    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.

  4. DASPRiD commented on Jul 19, 2022

    @DASPRiD
    Member

    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.

  5. b-art-xx commented on Jul 19, 2022

    @b-art-xx
    Author

    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.

  6. DASPRiD commented on Jul 19, 2022

    @DASPRiD
    Member

    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.

  7. arxeiss commented on Jul 20, 2022

    @arxeiss
    Contributor

    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.

  8. locked and limited conversation to collaborators on Mar 19, 2024
  9. converted this issue into a discussion #169 on Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions