laravel 无法加载 imagick 库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39609951/
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-09-14 14:29:07  来源:igfitidea点击:

Cannot load imagick library

phpapachelaravelimagick

提问by Jamal Abdul Nasir

I have installed the imagick from here(ImageMagick-7.0.3-1-Q16-x64-dll) and the dll (TS 32 bit) from here. And also copiend the CORE_RL_*to the C:\xampp\apache\binBUT still i get the following error when i run the laravel server.

我已经从安装在imagick这里(ImageMagick的-7.0.3-1-Q16-x64的DLL)和从DLL(TS 32位)在这里。并且还复制CORE_RL_*C:\xampp\apache\binBUT,但当我运行 Laravel 服务器时仍然出现以下错误。

ERROR: Warning: PHP Startup: Unable to load dynamic library 'C:\xampp\php\ext\php_imagick.dll' - The specified module could not be found. in Unknown on line 0

错误:警告:PHP 启动:无法加载动态库 'C:\xampp\php\ext\php_imagick.dll' - 找不到指定的模块。在未知的第 0 行

Also, I placed dll file in C:\xampp\php\ext\php_imagick.dll.

另外,我将 dll 文件放在C:\xampp\php\ext\php_imagick.dll.

Also, the imagick is shown in the phpinfo(). enter image description here

此外,imagick 显示在phpinfo(). 在此处输入图片说明

And when i use it using laravel i get the following error. enter image description here

当我使用 laravel 使用它时,出现以下错误。 在此处输入图片说明

回答by Avenyet

getting Imagick to work on windows has always been a bit hit and miss as pointed out here is a good guide http://stackoverflow.com/a/36378764/1090867

正如这里指出的那样,让 Imagick 在 Windows 上工作一直是一个很好的指南 http://stackoverflow.com/a/36378764/1090867

But it misses an important point

但它错过了一个重要的点

You do not need to put the binary into the PHP folder!

您不需要将二进制文件放入 PHP 文件夹!

So here are the steps I follow myself everytime I need to do this. This should work for apache, nginx or IIS.

因此,这是我每次需要执行此操作时自己遵循的步骤。这应该适用于 apache、nginx 或 IIS。

Step 1

第1步

find out your php version and setting

找出你的 php 版本和设置

enter image description here

在此处输入图片说明

You need to version, Architecture, Compiler and Thread Safety

您需要版本、架构、编译器和线程安全

if Thread Safety is disabled this is NTSis enabled it will TS

如果禁用线程安全,则启用NTS它将TS

Step 2

第2步

Get an install a copy of imageMagick it just make sure it mataches your Architecture, this also needs to be dll.exe rather that the static version.

获取一份 imageMagick 的安装副本,只需确保它与您的架构匹配,这也需要是 dll.exe 而不是静态版本。

Regarding Q8 and Q16 I'll leave that you to you but both versions will work

关于 Q8 和 Q16,我会留给你,但两个版本都可以使用

http://www.imagemagick.org/script/binary-releases.php#windows

http://www.imagemagick.org/script/binary-releases.php#windows

I recommend changing the install directory name to something geneeric like C:\Imagemagicksince I've had some problems in the past with te default directory name with PHP and windows.

我建议将安装目录名称更改为通用名称, C:\Imagemagick因为我过去在 PHP 和 Windows 的默认目录名称方面遇到了一些问题。

Just install but make sure you tick add application path and I normally tick the legacy utils as well.

只需安装,但请确保勾选添加应用程序路径,我通常也会勾选旧版实用程序。

enter image description here

在此处输入图片说明

Once its install go to your environment variables and make sure it is actually in the path. There is no need to copy anything to your php folder

安装后转到您的环境变量并确保它实际上在路径中。无需将任何内容复制到您的 php 文件夹中

Just to make sure everything is working open the command line and type convert --version you should get a reponse

只是为了确保一切正常,打开命令行并输入 convert --version 你应该得到响应

Step 3

第 3 步

This unfortantly is the hard part and can be a bit of trial and error. I've found the following provides the best php_imagick.dll that seems to work 9 times out of 10

不幸的是,这是困难的部分,可能需要反复试验。我发现以下提供了最好的 php_imagick.dll,它似乎在 10 次中有 9 次工作

http://www.peewit.fr/imagick/

http://www.peewit.fr/imagick/

Just pick the version that matches your install.

只需选择与您的安装匹配的版本即可。

If this doesn't work then go to php.net and try each version until one works... (start at the latest)

如果这不起作用,那么去 php.net 并尝试每个版本,直到一个有效......(最晚开始)

http://windows.php.net/downloads/pecl/releases/imagick/

http://windows.php.net/downloads/pecl/releases/imagick/

Once you have a php_imagick.dll put it into your php/ext/folder

一旦你有一个 php_imagick.dll 把它放到你的php/ext/文件夹中

thne locate your php.inifile go to the bottom (or whereever your extensions are) and add extension=php_imagick.dll

找到你的php.ini文件到底部(或任何你的扩展名)并添加extension=php_imagick.dll

Step 4

第四步

Restart PHP (or your computer) and it should be working if not try a different php_imagick.dll and repeat.

重新启动 PHP(或您的计算机),如果不尝试不同的 php_imagick.dll 并重复,它应该可以工作。

If the above doesn't work

如果以上方法不起作用

Then try a slightly older version of imagick I normally use version 6.8.6-8 Q16.

然后尝试稍旧版本的 imagick 我通常使用版本 6.8.6-8 Q16。

Please note I've only every really done this on Windows 7 and Windows Server 2008, 2008 R2, 2012 and 2012 R2 all x64 with x86 php

请注意,我只在 Windows 7 和 Windows Server 2008、2008 R2、2012 和 2012 R2 所有 x64 和 x86 php 上真正做到了这一点

If this still doesn't work then you probably need to copy over the CORE_RLfiles into your imagick directory this normally causes more issues but if you are running out idea then give it a go

如果这仍然不起作用,那么您可能需要将CORE_RL文件复制到您的 imagick 目录中,这通常会导致更多问题,但如果您没有想法,请试一试

回答by CubicleSoft

I just ran into this issue. Only I'm using PHP on the command line (PHP CLI). The problem is the dependencies that the main php_imagick.dllfile has. PHP will attempt to load the extension but since Windows can't find the CORE_RL_DLLs, the extension will fail to load and the error/warning message about being unable to load the DLL will appear. It helps to know how Windows loads DLLs:

我刚刚遇到了这个问题。只有我在命令行(PHP CLI)上使用 PHP。问题是主php_imagick.dll文件的依赖关系。PHP 将尝试加载扩展,但由于 Windows 找不到CORE_RL_DLL,扩展将无法加载,并且会出现关于无法加载 DLL 的错误/警告消息。它有助于了解 Windows 如何加载 DLL:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms682586(v=vs.85).aspx

https://msdn.microsoft.com/en-us/library/windows/desktop/ms682586(v=vs.85).aspx

It's pretty convoluted but you can see that the reason the Apache /bindirectory trick works with Apache is that httpd.exeis located in that directory. However, when using PHP CLI, the DLLs need to be located in the same directory as php.exe.

它非常复杂,但您可以看到 Apache/bin目录技巧与 Apache 一起使用的原因httpd.exe是位于该目录中。但是,在使用 PHP CLI 时,DLL 需要位于与php.exe.

If you don't want duplicate DLLs floating around, add the directory containing php.exeto the system PATH and plop all the CORE_RL_DLLs there. The PATH is the last thing searched, but it'll work fine. If you don't want spurious entries in your system PATH, then set the extra PATH information only during startup of Apache.

如果您不希望重复的 DLLphp.exe随处可见,请将包含的目录添加到系统 PATH 并将所有CORE_RL_DLL放入其中。PATH 是最后搜索的东西,但它会正常工作。如果您不想在系统 PATH 中出现虚假条目,则仅在 Apache 启动期间设置额外的 PATH 信息。