Search code examples
phpmysqllaravelimagick

spatie/pdf-to-image 1.8.2 requires ext-imagick Error in composer install


I am just picking up one legacy laravel project by using composer cli. I executed composer install but it's saying one Error spatie/pdf-to-image 1.8.2 requires ext-imagick Error. I couldn't figure it out. I guess it's because imagick extension wasn't set properly in php.ini. Anybody has ever faced on this kind of error before? Thank you in advance.


Solution

  • You didn't have the Imagick extension installed on your machine. Also you should make sure you have uncommented out Imagick.so in php.ini. You can follow up the next steps if you are using macOS.

    First, install imagemagick itself. This is needed to get the source files you’ll use later to compile the PHP extension with.

    brew install pkg-config imagemagick
    

    This will also install the needed pkg-config dependency.

    Second, use pecl to get the PHP extension compiled.

    pecl install imagick
    

    It will also auto-register itself in your php.ini and should now be available

    Lastly, test imagick extension would be available.

    php -m | grep -i magic
    

    This command would show imagick if it's properly set out.

    Note: if you run php-fpm, make sure you restart your daemon to load the latest extension. Use brew services restart php