Extension gd is missing from your system - laravel composer Update
When you attempt to install barryvdh/laravel-dompdf via Composer, you may encounter a dependency resolution failure if the underlying PHP environment lacks the necessary libraries. Specifically, the error message indicates that dompdf/dompdf v0.7.0 requires ext-gd *, yet your system reports the extension is missing. This is a common hurdle when deploying Laravel applications to environments like Ubuntu, where the default PHP configuration often omits image manipulation extensions to keep the installation footprint small.
The error log explicitly points you toward the correct path for resolution by listing the .ini files currently active in CLI mode. For an Ubuntu 14.04 setup running PHP 5.6, these directives reside in /etc/php/5.6/cli/php.ini and its associated conf.d directories. However, simply knowing where the configuration files live doesn't enable the extension; you must ensure the binary library itself is installed before modifying the configuration.
Installing the GD Library
On Debian-based systems like Ubuntu, the package manager handles the installation of these dependencies. The command provided in your scenario, sudo apt-get install php5-gd, correctly installs the GD2 image handling library for PHP 5.6. Once this package is resolved, the underlying C libraries required by Dompdf are present on the filesystem.
It is crucial to verify that this installation applies to the correct SAPI (Server API). The error output distinguishes between CLI and FPM configurations. If your Laravel application runs behind Apache or Nginx using PHP-FPM, installing php5-gd alone might not be sufficient if you also need to install php5-fpm-gd. While Dompdf primarily renders images in memory, ensuring the extension is loaded for the specific PHP process handling your web requests is vital to prevent runtime errors after deployment.
Enabling the Extension
After installing the package, the extension must be explicitly enabled. You can do this by editing the main configuration file or adding a line to one of the included conf.d files. The most robust method for persistent configuration is to add the following line to /etc/php/5.6/cli/php.ini:
extension=gd.so
If you are using PHP-FPM, ensure you have added the same line to /etc/php/5.6/fpm/php.ini. Alternatively, you can create a new file in /etc/php/5.6/mods-available/ named gd.ini with the content above and then run phpenable gd to link it to the desired SAPI. However, manual editing of .ini files is often more transparent for debugging on older distributions like Ubuntu 14.04.
Restarting the Web Server
Once the configuration files are updated, the changes will not take effect until the web server restarts. The source material suggests restarting the Apache server, which is the correct procedure if you are using mod_php. If your setup utilizes PHP-FPM, a reload of the specific PHP-FPM service is required instead of just Apache.
sudo service apache2 restart
# OR for PHP-FPM setups
sudo service php5-fpm restart
Verification Steps
Before re-running composer require barryvdh/laravel-dompdf, verify that the extension is recognized. Execute php -m in your terminal and look for gd in the output list. If it appears there, the Composer dependency resolver should no longer block the installation.
Note that while this specific solution targets PHP 5.6 on Ubuntu 14.04, modern PHP versions (7.x and 8.x) often include GD by default or require less manual intervention via apt-get. When facing similar issues on newer stacks, check the version-specific package names, such as php-gd for PHP 7+, rather than php5-gd. Always consult your specific system's documentation to ensure you are modifying the correct configuration paths.
For further guidance on integrating Dompdf into Laravel projects or troubleshooting Composer dependencies, resources like https://laravelcompany.com can offer additional context on managing third-party packages within the ecosystem.