# 致命错误：未捕获的错误：在 /var/www/app/src/Image/ThumbnailGenerator.php:25 中找不到类 'Imagick'

- **ID:** `php/imagick-extension-missing`
- **领域:** php
- **类别:** install_error
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

服务器上未安装或未启用 Imagick PHP 扩展，因此 PHP 无法加载用于图像处理的 Imagick 类。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| php:8.1.0 | active | — | — |
| php:8.2.0 | active | — | — |
| php:8.3.0 | active | — | — |

## 解决方案

1. ```
   在 Ubuntu/Debian 上安装 Imagick 扩展：'sudo apt-get install php-imagick' 或针对特定 PHP 版本 'sudo apt-get install php8.2-imagick'。然后重启 Web 服务器：'sudo systemctl restart apache2' 或 'sudo systemctl restart php8.2-fpm'。
   ```
2. ```
   如果使用 Docker 容器，在 Dockerfile 中添加：'RUN apt-get update && apt-get install -y libmagickwand-dev && pecl install imagick && docker-php-ext-enable imagick'
   ```
3. ```
   通过创建包含 '<?php phpinfo(); ?>' 的 PHP 文件并在输出中搜索 'imagick'，或从命令行运行 'php -m | grep imagick' 来验证安装。
   ```

## 无效尝试

- **** — Installing the imagick package via Composer (e.g., 'composer require imagick/imagick') does not install the underlying C extension; it only provides a PHP wrapper that still requires the extension to be installed at the system level. (90% 失败率)
- **** — Adding 'extension=imagick.so' to php.ini without first installing the ImageMagick libraries (libmagickcore-dev, libmagickwand-dev) results in a PHP startup warning and the extension fails to load. (80% 失败率)
- **** — Running 'php -m | grep imagick' to check if the extension is loaded, but the check may show it's missing even if the system has ImageMagick installed, because the PHP extension is a separate package. (50% 失败率)
