php 致命错误:找不到“imagick”类
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23026181/
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
Fatal error: Class 'imagick' not found
提问by Dev DOS
I am trying to install imagemagicphp extension under WampServer 2.
我正在尝试在 WampServer 2 下安装imagemagicphp 扩展。
I've downloaded and installed ImageMagick . I've chosen ImageMagick-6.8.8-10-Q16-x86-dll.exe
I've downloaded the php extension.
I've moved the dll extension I just downloaded to C:\wamp\bin\php\php5.4.16\ext\
I've altered php.ini (accessed it through wamp tray icon > right-click > PHP > php.ini) and added "extension=php_imagick.dll", without the quotes, to the extensions lists.
I restarted Apache. Not noticing the extension displayed on the PHP extensions list from the tray icon, I restarted the wampserver. ImageMagick extensions now shows enabled on the list.
我已经下载并安装了 ImageMagick 。我选择了 ImageMagick-6.8.8-10-Q16-x86-dll.exe
我已经下载了 php 扩展。
我已经将刚刚下载的 dll 扩展移到 C:\wamp\bin\php\php5.4.16\ext\
我已经更改了 php.ini(通过 wamp 托盘图标 > 右键单击 > PHP > php.ini 访问它)并将“extension=php_imagick.dll”(不带引号)添加到扩展列表中。
我重新启动了Apache。没有注意到托盘图标中 PHP 扩展列表上显示的扩展,我重新启动了 wampserver。ImageMagick 扩展现在在列表中显示已启用。
However, I cannot use it. Doing a quick test returns "Fatal error: Class 'Imagick' not found". In the phpinfo() shows only that the imagemagick has been added to env variables.
但是,我无法使用它。进行快速测试会返回“致命错误:未找到‘Imagick’类”。在 phpinfo() 中仅显示 imagemagick 已添加到 env 变量中。
when I try to test the imagick :
当我尝试测试 imagick 时:
$im = new imagick( 'test.jpg' );
// resize by 200 width and keep the ratio
$im->thumbnailImage( 200, 0);
// write to disk
$im->writeImage( 'test_thumbnail.jpg' );
I get the error:Fatal error: Class 'imagick' not found
What am I doing wrong?
I'm working with win7 32 bit, phph 5-4-16 and apache2
我收到错误消息:Fatal error: Class 'imagick' not found
我做错了什么?我正在使用 win7 32 位、phph 5-4-16 和 apache2
采纳答案by Dev DOS
The only way that I make it works is by using an older version of imagick:php_imagick-3.2.0b1-5.4-nts-vc9-x86
.
我让它工作的唯一方法是使用旧版本的 imagick: php_imagick-3.2.0b1-5.4-nts-vc9-x86
。
回答by Amadu Bah
- Try:
php -m | grep imagick
. - If the result is empty do:
sudo apt-get remove --purge php5-imagick && sudo apt-get install php5-imagick
- 试试:
php -m | grep imagick
。 - 如果结果为空,请执行以下操作:
sudo apt-get remove --purge php5-imagick && sudo apt-get install php5-imagick
Regards
问候
回答by Joe Okatch
You might be having mis-aligned library versions.
您可能有未对齐的库版本。
Here's how I solved it
这是我解决的方法
I had really struggled with all these answers. Looking back I realised most of them are correct except they leave out some very finedetails that are crucial.
我真的为所有这些答案而挣扎。回顾过去,我意识到他们中的大多数都是正确的,只是他们遗漏了一些非常重要的细节。
1).First and foremost, before you start downloading any libraries or DLLs you want to start with your php_infoto find out these three very important parameters.
1)。首先,在您开始下载任何库或 DLL 之前,您要从 php_info开始找出这三个非常重要的参数。
Run the PHP_Info and check:
运行 PHP_Info 并检查:
- Architecture : x86 or x64. Your computer might be x64 but your php is running on x86 so don't assume
- Thread Safety : yes or no. Also very important.
- Your PHP Version
- 架构:x86 或 x64。您的计算机可能是 x64,但您的 php 在 x86 上运行,所以不要假设
- 线程安全:是或否。也非常重要。
- 您的 PHP 版本
2).Download ImageMagick from: https://windows.php.net/downloads/pecl/deps/. My computer is x64 but my php is running x86 so I downloaded ImageMagick-7.0.--vc*-x86.zip
2)。从以下位置下载 ImageMagick:https: //windows.php.net/downloads/pecl/deps/。我的电脑是 x64,但我的 php 运行的是 x86,所以我下载了 ImageMagick-7.0。--vc*-x86.zip
3).Unzip and copy all DLLs from the unzipped bin subfolder to the Apache bin directory. It's a bunch of CORE_RL_.dll and IM_MOD_RL_.dll plus a few other DLLs. In my case, [zippeddownload]/bin/* ->copied to -> C:\Xampp\apache\bin
3)。解压缩所有 DLL 并将其从解压缩的 bin 子文件夹复制到 Apache bin 目录。它是一堆 CORE_RL_ .dll 和 IM_MOD_RL_.dll 加上一些其他 DLL。就我而言,[zippeddownload]/bin/* -> 复制到 -> C:\Xampp\apache\bin
4).Go to http://pecl.php.net/package/imagick. You can select the zip link or just the DLL link. I prefer the DLL link. In my case I selected latest version 3.4.3. Which then took me to https://pecl.php.net/package/imagick/3.4.3/windows. Here we have to make another careful choice
4)。转到http://pecl.php.net/package/imagick。您可以选择 zip 链接或仅选择 DLL 链接。我更喜欢 DLL 链接。就我而言,我选择了最新版本 3.4.3。然后带我到https://pecl.php.net/package/imagick/3.4.3/windows。到这里我们又要慎重选择了
- My php version is PHP 5.6
- Thread Safety is enabled
- Architecture php is running on is x86
- So I took 5.6 Thread Safe (TS) x86
- 我的 php 版本是PHP 5.6
- 线程安全已启用
- 正在运行的架构 php 是x86
- 所以我拿了5.6 线程安全 (TS) x86
5).Unzip and copy "php_imagick.dll" to the php extfolder. And all other DLL files to the php folder
5)。解压并复制“php_imagick.dll”到 php ext文件夹。和所有其他 DLL 文件到 php 文件夹
6).Using an editor open php.ini. Search for "extension=" and add this line extension=php_imagick.dllas one of them.
6). 使用编辑器打开php.ini。搜索“extension=”并将这一行extension=php_imagick.dll添加为其中之一。
7).Restart Xampp/Wamp or just restart Apache and run PHP_INFO again. Imagick should display. If you still can't see it refer to this link http://php.net/manual/en/imagick.setup.php#119084
7)。重新启动 Xampp/Wamp 或只是重新启动 Apache 并再次运行 PHP_INFO。Imagick 应该显示。如果您仍然看不到它,请参阅此链接http://php.net/manual/en/imagick.setup.php#119084
Bonus tip:You might need to download visual c++ 14 runtime. From this link https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloadsI chose the latest version.
额外提示:您可能需要下载visual c++ 14 runtime。从这个链接https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads我选择了最新版本。
回答by Won Jun Bae
apt-get install pkg-config libmagickwand-dev -y
cd /tmp
wget https://pecl.php.net/get/imagick-3.4.0.tgz
tar xvzf imagick-3.4.0.tgz
cd imagick-3.4.0
phpize
./configure
make install
rm -rf /tmp/imagick-3.4.0*
echo extension=imagick.so >> /etc/php/7.0/cli/php.ini
echo extension=imagick.so >> /etc/php/7.0/fpm/php.ini
service php7.0-fpm restart
service nginx restart
回答by Paulo Amaral
Did you try using the proper casing for the class, starting with capital "i"?
您是否尝试为类使用正确的大小写,以大写“i”开头?
$im = new Imagick( 'test.jpg' );
In php, class and files names and not case-sensitive, but classloaders are.
在 php 中,类和文件名不区分大小写,但类加载器是。
回答by earnest
do a <?php phpinfo(); ?>
in any page. This will show all the services running on the service. If it is running then it will show you in which directory.
<?php phpinfo(); ?>
在任何页面上做一个。这将显示在该服务上运行的所有服务。如果它正在运行,那么它将显示在哪个目录中。
If you are using WHM panel you might have to install imageMagick there
如果您使用 WHM 面板,您可能需要在那里安装 imageMagick