如何使用 Composer 添加 php gd (laravel 8)

发布于 2025-01-19 20:54:09 字数 468 浏览 5 评论 0原文

我试图将PHP GD添加到Composer.json。 我想安装PHP GD,因为有以下错误:

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

错误是由DOMPDF引起的,因为DOMPDF需要PHP GD处理图像。 我尝试了以下命令:

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

没有任何结果,即使艰难的Ext-GD也添加到了作曲家。 有人知道解决我问题的解决方案吗? 预先感谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我不咬妳我踢妳 2025-01-26 20:54:09

您无法使用 Composer 安装 GD。 Composer 管理您的项目依赖的其他 PHP 源,但 GD 不是 PHP 源 - 它是一个原生 PHP 扩展模块,如 ext-curl 或 ext-mysqli 。将ext-gd:* 添加到您的composer.json 只是意味着“该项目需要安装GD 扩展”。为了实际安装该扩展,您需要使用操作系统级工具。如果您使用的是基于 Debian 的系统,则可能类似于:

sudo apt install php-gd

或者,对于基于 RedHat 的系统,类似于:

sudo dnf install php-gd

完成后,再次运行 composer install,您应该好的。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文