Home > Software engineering >  how to add php gd with composer (laravel 8)
how to add php gd with composer (laravel 8)

Time:04-08

I trying to add php gd to the composer.json. I want to install php gd because of the following error :

The PHP GD extension is required, but is not installed.

The error was caused by dompdf as dompdf requires php gd to process images. I tried the following command :

composer require "ext-gd:*" --ignore-platform-reqs

Without any result even tough ext-gd was added to the composer.json. Does anyone know a solution to my problem? Thank in advance.

CodePudding user response:

You can't install GD with Composer. Composer manages other PHP source that your project relies on, but GD is not PHP source -- it's a native PHP extension module like ext-curl or ext-mysqli. Adding ext-gd:* to your composer.json simply means, "This project requires the GD extension to be installed." In order to actually install that extension, you'll need to drop to your OS-level tools. If you're on a Debian-based system, that'll likely be something like:

sudo apt install php-gd

Or, for a RedHat-based system, something like:

sudo dnf install php-gd

Once done, run your composer install again and you should be good.

  • Related