Extension gd is missing from your system - laravel composer Update

PhpLaravelLaravel 5.2Gd

Php Problem Overview


I newly install Dompdf in Laravel Project via Composer (composer require barryvdh/laravel-dompdf). After enter the Command Terminal Reply Following Errors.

Problem 1
    - dompdf/dompdf v0.7.0 requires ext-gd * -> the requested PHP extension gd is missing from your system.
    - barryvdh/laravel-dompdf v0.7.0 requires dompdf/dompdf ^0.7 -> satisfiable by dompdf/dompdf[v0.7.0].
    - Installation request for barryvdh/laravel-dompdf ^0.7.0 -> satisfiable by barryvdh/laravel-dompdf[v0.7.0].

  To enable extensions, verify that they are enabled in those .ini files:
    - /etc/php/5.6/cli/php.ini
    - /etc/php/5.6/cli/conf.d/10-opcache.ini
    - /etc/php/5.6/cli/conf.d/10-pdo.ini
    - /etc/php/5.6/cli/conf.d/15-xml.ini
    - /etc/php/5.6/cli/conf.d/20-calendar.ini
    - /etc/php/5.6/cli/conf.d/20-ctype.ini
    - /etc/php/5.6/cli/conf.d/20-dom.ini
    - /etc/php/5.6/cli/conf.d/20-exif.ini
    - /etc/php/5.6/cli/conf.d/20-fileinfo.ini
    - /etc/php/5.6/cli/conf.d/20-ftp.ini
    - /etc/php/5.6/cli/conf.d/20-gettext.ini
    - /etc/php/5.6/cli/conf.d/20-iconv.ini
    - /etc/php/5.6/cli/conf.d/20-json.ini
    - /etc/php/5.6/cli/conf.d/20-mbstring.ini
    - /etc/php/5.6/cli/conf.d/20-phar.ini
    - /etc/php/5.6/cli/conf.d/20-posix.ini
    - /etc/php/5.6/cli/conf.d/20-readline.ini
    - /etc/php/5.6/cli/conf.d/20-shmop.ini
    - /etc/php/5.6/cli/conf.d/20-simplexml.ini
    - /etc/php/5.6/cli/conf.d/20-sockets.ini
    - /etc/php/5.6/cli/conf.d/20-sysvmsg.ini
    - /etc/php/5.6/cli/conf.d/20-sysvsem.ini
    - /etc/php/5.6/cli/conf.d/20-sysvshm.ini
    - /etc/php/5.6/cli/conf.d/20-tokenizer.ini
    - /etc/php/5.6/cli/conf.d/20-wddx.ini
    - /etc/php/5.6/cli/conf.d/20-xmlreader.ini
    - /etc/php/5.6/cli/conf.d/20-xmlwriter.ini
    - /etc/php/5.6/cli/conf.d/20-xsl.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

How to Solve this Error

I already Installed GD using Following comment. sudo apt-get install php5-gd and also Apache Server Restarted. My Laravel Version is 5.3 and Ubuntu Version is 14.04

Php Solutions


Solution 1 - Php

I have installed php7, I did the following to solve exactly the same error

sudo apt-get install php7.0-gd
sudo apt-get install php7.0-intl
sudo apt-get install php7.0-xsl

Solution 2 - Php

If you are working in PHP version 5.* then you have to install

sudo apt-get install php5-gd

And if you are working in PHP version 7.* then you have to install

sudo apt-get install php7.0-gd

Hope it will work...

And if you are working in PHP version 7.2 then you have to install

sudo apt-get install php7.2-gd... it worked for me

Solution 3 - Php

Open your php.ini and uncomment this line:

;extension=php_gd2.dll

Solution 4 - Php

It may not be enabled for php-cli, you can enable like this;

sudo phpenmod gd

UPDATE

I guess, you are using ppa:ondrej php package (5.6), which is confusing you with default ubuntu 14.04 php package (5.5.9).

To install php 5.6 gd library from ppa:ondrej, you should use:

sudo apt-get install php5.6-gd

Solution 5 - Php

For php-8, just locate your php.ini file and uncomment the line extension=gd
Below is a picture guide for those using Xampp and Windows

Step 1: Open php.ini or locate it in your machine (C:/xampp/php/php.ini)

Open php.ini or locate it in your machine (C:/xampp/php/php.ini)

Step 2: Uncomment the line extension=gd by removing the semicolon

Uncomment the line extension=gd by removing the semicolon

Step 3: Save your file and restart your services

Save your file and restart your services

Solution 6 - Php

PHP 7.4.2 (cli) (built: Feb 5 2020 16:50:21) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.2, Copyright (c), by Zend Technologies

For Php 7.4.2

  1. sudo apt-get install php7.4-gd
  2. sudo phpenmod gd

Solution 7 - Php

Before installing the missing dependency, you need to check which version of PHP is installed on your system.

php -v
PHP 7.2.10-0ubuntu0.18.04.1 (cli) (built: Sep 13 2018 13:45:02) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.10-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies

In this case it's php7.2. apt search php7.2 returns all the available PHP extensions.

apt search php7.2
Sorting... Done
Full Text Search... Done
libapache2-mod-php7.2/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
  server-side, HTML-embedded scripting language (Apache 2 module)

libphp7.2-embed/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
  HTML-embedded scripting language (Embedded SAPI library)

php-all-dev/bionic,bionic 1:60ubuntu1 all
  package depending on all supported PHP development packages

php7.2/bionic-updates,bionic-updates,bionic-security,bionic-security 7.2.10-0ubuntu0.18.04.1 all
  server-side, HTML-embedded scripting language (metapackage)

php7.2-bcmath/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
  Bcmath module for PHP

php7.2-bz2/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
  bzip2 module for PHP

php7.2-cgi/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
  server-side, HTML-embedded scripting language (CGI binary)

php7.2-cli/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
  command-line interpreter for the PHP scripting language

php7.2-common/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
  documentation, examples and common module for PHP

php7.2-curl/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed]
  CURL module for PHP

php7.2-dba/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
  DBA module for PHP

php7.2-dev/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
  Files for PHP7.2 module development

php7.2-enchant/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
  Enchant module for PHP

php7.2-fpm/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed]
  server-side, HTML-embedded scripting language (FPM-CGI binary)

php7.2-gd/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed]
  GD module for PHP

php7.2-gmp/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
  GMP module for PHP

php7.2-imap/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
  IMAP module for PHP

php7.2-interbase/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
  Interbase module for PHP

php7.2-intl/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
  Internationalisation module for PHP

php7.2-json/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
  JSON module for PHP

php7.2-ldap/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
  LDAP module for PHP

php7.2-mbstring/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
  MBSTRING module for PHP

php7.2-mysql/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
  MySQL module for PHP

php7.2-odbc/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
  ODBC module for PHP

php7.2-opcache/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
  Zend OpCache module for PHP

php7.2-pgsql/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
  PostgreSQL module for PHP

php7.2-phpdbg/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
  server-side, HTML-embedded scripting language (PHPDBG binary)

php7.2-pspell/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
  pspell module for PHP

php7.2-readline/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed,automatic]
  readline module for PHP

php7.2-recode/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
  recode module for PHP

php7.2-snmp/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
  SNMP module for PHP

php7.2-soap/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
  SOAP module for PHP

php7.2-sqlite3/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed]
  SQLite3 module for PHP

php7.2-sybase/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
  Sybase module for PHP

php7.2-tidy/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
  tidy module for PHP

php7.2-xml/bionic-updates,bionic-security,now 7.2.10-0ubuntu0.18.04.1 amd64 [installed]
  DOM, SimpleXML, WDDX, XML, and XSL module for PHP

php7.2-xmlrpc/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
  XMLRPC-EPI module for PHP

php7.2-xsl/bionic-updates,bionic-updates,bionic-security,bionic-security 7.2.10-0ubuntu0.18.04.1 all
  XSL module for PHP (dummy)

php7.2-zip/bionic-updates,bionic-security 7.2.10-0ubuntu0.18.04.1 amd64
  Zip module for PHP

You can now proceed to installing the missing dependency by running:

sudo apt install php7.2-gd

Solution 8 - Php

if you are working in PHP version 7.2 then you have to install

sudo apt-get install php7.2-gd

Solution 9 - Php

For php 7.1

sudo apt-get install php7.1-gd

Cheers!

Solution 10 - Php

The solution is quite simple.

In your php.ini, just uncomment the line extension=php_gd2.dll (or .so extension for unix systems.)

Hope it helps.

Solution 11 - Php

This worked for me:

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

Solution 12 - Php

As of Composer 2.0 on Arch, I use: --ignore-platform-req=ext-gd

Eg:

php composer install -n --ignore-platform-req=ext-gd

Eg: (to ignore multiple requirements)

php composer install -n --ignore-platform-req=ext-gd --ignore-platform-req=ext-ldap

Ignoring Composer requirements may be necessary because Composer may return false warnings on dependencies that are already properly installed and enabled, consider this Arch forum article:

> I have installed php-gd and uncommeted extension=gd.so in /etc/php/php.ini as the wiki says

Thanks for this answer on a related Question, How to always use ignore-platform-reqs flag when running composer?

Solution 13 - Php

Using Manjaro(Arch) Linux:

$ sudo pacman -S php-gd

In file /etc/php/php-ini, add the line:

extension=gd.so

Solution 14 - Php

For Windows : Uncomment this line in your php.ini file

;extension=php_gd2.dll

If the above step doesn't work uncomment the following line as well:

;extension=gd2

Solution 15 - Php

I'm working on php 8.0.9, and I just uncomment this on php.ini in xampp/php/php.ini directory.

from

;extension=gd

to

extension=gd

and it's work normal again

Solution 16 - Php

sudo apt-get install php7.4-zip

Use your version of php. Like here I used 7.4

Solution 17 - Php

On CentOS 7, try running following command:

sudo yum install php72u-gd.x86_64

Solution 18 - Php

in docker I found a same problem, even after "rm /etc/apt/preferences.d/no-debian-php" then "apt update" "apt install php7.4-gd"

"php composer.phar update" error " ..... ext-gd ....." so my solution is direct using php7.4 "php7.4 composer.phar update"

and its work. I dont know why.

Solution 19 - Php

It may help you

apt install php-xml

systemctl restart apache2

From reference here, you may learn in brief.

Thanks :)

Solution 20 - Php

PHP VERSION - 7.3.21
WAMP SERVER

// use below command to fix ext-gd issue
// work for me
composer require "ext-gd:*" --ignore-platform-reqs phpoffice/phpspreadsheet

Solution 21 - Php

On Local or Xampp in windows go to : C:\xampp\php\php.ini

uncomment extension=gd

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKarthikView Question on Stackoverflow
Solution 1 - PhpEleazar ResendezView Answer on Stackoverflow
Solution 2 - PhpAbhinav GuptaView Answer on Stackoverflow
Solution 3 - PhpHFrancoView Answer on Stackoverflow
Solution 4 - PhphasandzView Answer on Stackoverflow
Solution 5 - PhpLeftyView Answer on Stackoverflow
Solution 6 - PhpParvindView Answer on Stackoverflow
Solution 7 - PhpRobView Answer on Stackoverflow
Solution 8 - Phpkhushbu vaishnavView Answer on Stackoverflow
Solution 9 - PhpMichelView Answer on Stackoverflow
Solution 10 - PhptomrlhView Answer on Stackoverflow
Solution 11 - PhpSalehView Answer on Stackoverflow
Solution 12 - PhpJesse Steele יִשַׁיView Answer on Stackoverflow
Solution 13 - PhpGiovani de QuadrosView Answer on Stackoverflow
Solution 14 - PhpAshutosh AnandView Answer on Stackoverflow
Solution 15 - PhpAhmad RindhoniView Answer on Stackoverflow
Solution 16 - PhpAnuragView Answer on Stackoverflow
Solution 17 - PhpAkshay LokurView Answer on Stackoverflow
Solution 18 - Phpedi kemputView Answer on Stackoverflow
Solution 19 - PhpYagnesh bhalalaView Answer on Stackoverflow
Solution 20 - PhpSonu ChohanView Answer on Stackoverflow
Solution 21 - PhpaqibGenkView Answer on Stackoverflow