Install PHP imagick on Windows, MacOS with Laragon and Laravel Herd

- Andrés Cruz

En español

In this entry, we will explain how to install the Imagick DLL on Windows and MacOS, in the Laragon and Laravel Herd environments; this is an extension used for image manipulation in PHP and is used internally by many PHP packages as QR code generators.

Add Imagick in Laragon

Let's see the steps on how to generate the DLL in Windows with Laragon; the first thing we must do is go to the official website whose link I leave at the end of the post and download the version that satisfies your version of PHP and that is not thread safe for Laragon. Once downloaded, we must unzip the zip and copy the DLL called php_imagick.dll into the php folder called ext and make sure to right click on the file, properties and unlock it.

The next step is to go to your Laragon and enable it:

DLLs extensiones en Laragon

In case you cannot enable it or Apache does not recognize the process, you can add the extension directly to your php.ini:

PHP ini laragon

In php.ini, find where extensions are defined by searching for extension= and add the line:

extension=imagick

You should see something like:

extension=curl
;extension=ffi
;extension=ftp
extension=fileinfo
extension=gd
;extension=gettext
;extension=gmp
extension=intl
;extension=imap
extension=mbstring
extension=exif      ; Must be after mbstring as it depends on it
extension=mysqli
;extension=oci8_12c  ; Use with Oracle Database 12c Instant Client
;extension=oci8_19  ; Use with Oracle Database 19 Instant Client
;extension=odbc
extension=openssl
;extension=pdo_firebird
extension=pdo_mysql
;extension=pdo_oci
;extension=pdo_odbc
;extension=pdo_pgsql
extension=pdo_sqlite
extension=imagick

If it still does not recognize the DLL, you can edit the environment variables, the PATH, and the Imagick extension.

Right click on computer, open "Edit system environment variables", click Environment variables, select PATH, edit and add the path to the final Imagick folder.

If you don't add the PATH of the Imagick folder to your system environment path, php will throw an extension not found error even if the dll is there.

Add extensions in Laravel Herd

Installing additional extensions requires you to install PHP through Homebrew in order to compile them.

You can do this by running:

brew install php

Once PHP is installed via Homebrew, you can install the extension:

pecl install [extension-name]

Conclusions

In this entry, we saw some fundamental steps to be able to install the Imagick DLL in our system in various environments. The steps are generally the same but, depending on the environment, you may have to make some variants like those presented in this entry.

Recommended links:

https://mlocati.github.io/articles/php-windows-imagick.html

https://herd.laravel.com/docs/1/advanced-usage/additional-extensions

Andrés Cruz

Develop with Laravel, Django, Flask, CodeIgniter, HTML5, CSS3, MySQL, JavaScript, Vue, Android, iOS, Flutter

Andrés Cruz In Udemy

I agree to receive announcements of interest about this Blog.