php Laravel Intervention Image GD 库扩展

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39990516/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:04:21  来源:igfitidea点击:

Laravel Intervention Image GD library extension

phplaravel

提问by Kavinda Keshan Rasnayake

First of all, I am sorry if my question may be too vague. So, I will try to clarify my question as much as possible.

首先,如果我的问题可能太模糊,我很抱歉。所以,我会尽量澄清我的问题。

I am currently developing a Laravel application, and I am trying to use Intervention Image Facade. When I tried to use it to test an upload, I got the following error:-

我目前正在开发一个 Laravel 应用程序,我正在尝试使用 Intervention Image Facade。当我尝试使用它来测试上传时,出现以下错误:-

NotSupportedException in Driver.php line 16: GD Library extension not available with this PHP installation.

So, as I would try to do, I installed the GD library using sudo apt-get install libgd3and the php gd driver using sudo apt-get php5.6-gd. However, this did not work, and the same error keeps popping up in laravel. What have I clearly missed, and what should I follow next?

因此,正如我尝试做的那样,我sudo apt-get install libgd3使用sudo apt-get php5.6-gd. 但是,这不起作用,并且在 laravel 中不断弹出相同的错误。我显然错过了什么,接下来我应该遵循什么?

Edit 1.I used the following command to see if php actually supports gd driver : - php -i | grep -i --color gd

编辑 1.我使用以下命令查看 php 是否真的支持 gd 驱动程序:-php -i | grep -i --color gd

The following result came: -

结果如下:-

/etc/php/5.6/cli/conf.d/20-gd.ini,
gd
GD Support => enabled
GD headers Version => 2.2.3
GD library Version => 2.2.3
gd.jpeg_ignore_warning => 0 => 0
GDM_LANG => en_US
GDMSESSION => ubuntu
_SERVER["GDM_LANG"] => en_US
_SERVER["GDMSESSION"] => ubuntu

Hope this helps even more.

希望这有助于更多。

EDIT 2Thanks to all who answered. I found my solution in Mayank Pandey's answer.

编辑 2感谢所有回答的人。我在 Mayank Pandey 的回答中找到了我的解决方案。

回答by Mayank Pandeyz

This is because the GD Library is missing on your server.

这是因为您的服务器上缺少 GD 库。

You must enable the library GD2.

您必须启用库 GD2。

Find your (proper) php.inifile, and then find the line:

找到您的(正确的)php.ini文件,然后找到以下行:

;extension=php_gd2.dll, remove the semicolon in the front. ;means the line is commented, so remove the comment)

;extension=php_gd2.dll, 去掉前面的分号。;表示该行已被注释,因此删除注释)

The line should look like this:

该行应如下所示:

extension=php_gd2.dll

extension=php_gd2.dll

Then restart apache and you are ready to go.

然后重新启动 apache,您就可以开始了。

回答by thewebcompiler

Install GD extension:

安装 GD 扩展:

sudo apt-get install php7.0-gd

For PHP 7.1 try the following:

对于 PHP 7.1,请尝试以下操作:

sudo apt-get install php7.1-gd

For PHP 7.2 try the following:

对于 PHP 7.2,请尝试以下操作:

sudo apt-get install php7.2-gd

Then restart your server.

然后重启你的服务器。

Apache:

阿帕奇:

sudo service apache2 restart

Nginx:

nginx:

sudo service nginx restart

回答by Doreen Chemweno

After all the above failed, I upgraded to php 7.3.x from php7.2.x, using

以上都失败后,我从php7.2.x升级到php 7.3.x,使用

    sudo apt install php

then installed gd

然后安装gd

    sudo apt-get install php7.3-gd

to be sure, restart the apache server or xampp(as was for my case) and also restart php artisan serve.

可以肯定的是,重新启动 apache 服务器或 xampp(就像我的情况一样)并重新启动 php artisan serve。

Using the appropriate php.ini file, ensure that "extension=php_gd2.dll" is enabled by removing the semicolon that appears before it.

使用适当的 php.ini 文件,通过删除出现在它前面的分号来确保启用“extension=php_gd2.dll”。

then check what you have on grep through

然后检查你在 grep 上的内容

    php -i | grep -i --color gd

it should look like this.

它应该是这样的。

/etc/php/7.3/cli/conf.d/20-gd.ini,
gd
GD Support => enabled
GD headers Version => 2.2.5
GD library Version => 2.2.5
gd.jpeg_ignore_warning => 1 => 1
GDM_LANG => C.UTF-8
GDMSESSION => gnome
XAUTHORITY => /run/user/1000/gdm/Xauthority
$_SERVER['GDM_LANG'] => C.UTF-8
$_SERVER['GDMSESSION'] => gnome
$_SERVER['XAUTHORITY'] => /run/user/1000/gdm/Xauthority

in the case that after this, you get an error concerning drivers on your laravel app, this answer may help solve it.Laravel 5 PDOException Could Not Find Driver

如果在此之后,您在 Laravel 应用程序上收到有关驱动程序的错误,此答案可能有助于解决此问题。Laravel 5 PDOException 找不到驱动程序

I hope this helps you.

我希望这可以帮助你。

回答by Frank LAN

Did you enable the gd extension?

你启用了gd扩展吗?

try this is your termital

试试这是你的终端

php -i | grep gd

my output is:

我的输出是:

frank@frank-ThinkPad-T430:~$ php -i | grep gd
/etc/php/7.0/cli/conf.d/20-gd.ini,
gd
gd.jpeg_ignore_warning => 0 => 0