当前位置:首页>php>PHP 图片处理全实战:压缩、水印、裁剪、WebP 转换,直接复制可用

PHP 图片处理全实战:压缩、水印、裁剪、WebP 转换,直接复制可用

  • 2026-03-24 08:48:39
PHP 图片处理全实战:压缩、水印、裁剪、WebP 转换,直接复制可用

大家好,我是专注 PHP 实战干货的博主。

前面我们讲了开发工具、.gitignore、统一返回、MySQL 索引、优雅调试、PHP PSR 规范、常用助手函数、接口限流、接口签名验证、全局异常处理,今天给大家带来PHP 图片处理核心技能:压缩、水印、裁剪、WebP 转换—— 告别第三方工具,本地一键处理,适配移动端 / 小程序,大幅降低服务器存储和加载耗时。

日常开发中图片处理是高频痛点:
  • 用户上传的图片几 M 甚至几十 M,加载慢、占空间;
  • 小程序 / APP 需要不同尺寸的图片(封面、缩略图、头像);
  • 原创图片被盗用,需要加水印保护;
  • 普通 JPG/PNG 体积大,WebP 格式能省 50% 空间但不会转。
这篇整合了一套无依赖、可直接复制、兼容所有 PHP 环境的图片处理工具类,覆盖压缩、水印、裁剪、WebP 转换四大核心需求,上线就能用。
功能模块
方法名
详细描述
🖼️ 图片加载
__construct
支持 JPG, PNG, GIF, WebP 格式。自动校验文件存在性、格式合法性及路径安全性。
📉 智能压缩
compress
双重压缩:1. 尺寸缩放:按最大宽/高自动等比例缩放。2. 质量压缩:设置 1-100 的压缩质量。(完美保留 PNG 透明通道)
✂️ 精准裁剪
crop
支持指定宽高裁剪。提供 居中 (center) 和 左上 (top_left) 两种模式,自动处理边界溢出。
🔤 文字水印
addTextWatermark
支持 TrueType 字体 (.ttf)。可自定义字号、RGB 颜色、位置(居中/右下)、透明度。自动校验字体文件路径安全。
🖌️ 图片水印
addImageWatermark
支持叠加另一张图片(推荐 PNG)。可自定义缩放比例 (scale)、透明度 (alpha)、位置。自动处理水印资源释放。
🔄 格式转换
toWebP
一键将图片标记为 WebP 格式(需服务器 GD 库支持),通常可减少 50% 体积。包含环境兼容性检查。
💾 安全保存
save
自动创建目录。根据类型调用对应保存函数。严格校验保存路径是否在允许范围内,并检查写入权限。
一、前置准备:启用 GD 库(必看)
1.PHP 图片处理依赖GD库,先检查并启用:
查看是否安装:php -m | grep gd(终端执行);
2.未安装则安装:
Linux
yum install php-gd #或者(看系统不同用不同的命令)apt install php-gd;
Windows:
打开php.ini,取消注释extension=gd2;
3.重启 Web 服务(Nginx/Apache)。
二、完整图片处理工具类(核心代码,直接复制,已经兼容php7)
<?php/** * PHP图片处理工具类(生产级) * 支持:压缩、水印、裁剪、WebP转换 * 依赖:GD库(PHP>=7.0) * 优化:PNG透明防黑底、路径遍历安全、资源自动释放、全异常防护 */classImageHandler{    // 原图片路径    private $srcPath;    // 图片资源    private $image;    // 图片类型(jpg/png/gif/webp)    private $type;    // 图片宽高    private $width;    private $height;    // 压缩质量    private $quality;    // 允许的图片存储根目录(限制路径遍历)    private $allowedRootDir;    /**     * 初始化图片     * @param string $srcPath 图片路径     * @param string $allowedRootDir 允许的根目录(默认当前目录,限制路径遍历)     * @throws Exception 图片不存在/不支持/路径非法     */    public function __construct(string $srcPathstring $allowedRootDir __DIR__)    {        // 优化:路径规范化,防止路径遍历攻击        $this->allowedRootDir = realpath($allowedRootDir);        if($this->allowedRootDir === false) {            throw new Exception('允许的根目录不存在:' . $allowedRootDir);        }        // 规范化源路径,解析真实路径        $realSrcPath realpath($srcPath);        if($realSrcPath === false) {            throw new Exception('图片文件不存在或路径非法:' . $srcPath);        }        // 检查路径是否在允许的根目录内(防止../../etc/passwd等遍历)        if(strpos($realSrcPath$this->allowedRootDir) !== 0) {            throw new Exception('非法路径:不允许访问根目录外的文件');        }        $this->srcPath = $realSrcPath;        // 获取图片信息        $info getimagesize($this->srcPath);        if(!$info || !isset($info[2])) {            throw new Exception('无法识别图片格式');        }        // 检查image_type_to_extension入参有效性        $imageExt image_type_to_extension($info[2], false);        if(!$imageExt) {            throw new Exception('不支持的图片类型:' . $info[2]);        }        $this->type = strtolower($imageExt);        $this->width = $info[0];        $this->height = $info[1];        // 创建图片资源        $this->createImageResource();    }    /**     * 析构函数:确保图片资源自动释放(优化:防止内存泄漏)     */    public function __destruct()    {        if($this->image && is_resource($this->image)) {            imagedestroy($this->image);            $this->image = null// 清空引用        }    }    /**     * 创建图片资源     */    private function createImageResource()    {        switch($this->type) {            case 'jpg':            case 'jpeg':                $this->image = imagecreatefromjpeg($this->srcPath);                break;            case 'png':                $this->image = imagecreatefrompng($this->srcPath);                // 保留PNG透明通道                imagesavealpha($this->image, true);                break;            case 'gif':                $this->image = imagecreatefromgif($this->srcPath);                break;            case 'webp':                $this->image = imagecreatefromwebp($this->srcPath);                break;            default:                throw new Exception('不支持的图片格式:' . $this->type);        }        if(!$this->image) {            throw new Exception('创建图片资源失败');        }    }    /**     * 图片压缩(按质量/尺寸)     * @param int $quality 压缩质量(1-100,越低越小)     * @param int $maxWidth 最大宽度(0=不限制)     * @param int $maxHeight 最大高度(0=不限制)     * @return $this     */    public function compress(int $quality 80int $maxWidth 0int $maxHeight 0): self    {        // 限制质量范围,避免无效值        $this->quality = max(1min(100$quality));        // 等比例缩放        if($maxWidth 0 || $maxHeight 0) {            $scale 1;            if($maxWidth 0 && $this->width > $maxWidth) {                $scale $maxWidth $this->width;            }            if($maxHeight 0 && $this->height * $scale $maxHeight) {                $scale $maxHeight $this->height;            }            if($scale 1) {                $newWidth = (int)($this->width * $scale);                $newHeight = (int)($this->height * $scale);                // 创建新画布                $newImage imagecreatetruecolor($newWidth$newHeight);                if(!$newImage) {                    throw new Exception('创建画布失败,可能内存不足');                }                // 优化:PNG透明背景增强处理(绝对防止黑底)                if($this->type == 'png') {                    imagealphablending($newImagefalse);                    imagesavealpha($newImagetrue);                    // 填充完全透明的背景色(alpha=127表示完全透明)                    $transparent imagecolorallocatealpha($newImage000127);                    imagefill($newImage00$transparent);                }                // 图片重采样                $result imagecopyresampled(                    $newImage$this->image,                    0000,                    $newWidth$newHeight,                    $this->width, $this->height                );                if(!$result) {                    throw new Exception('图片压缩失败');                }                // 释放旧资源                imagedestroy($this->image);                $this->image = $newImage;                $this->width = $newWidth;                $this->height = $newHeight;            }        }        return $this;    }    /**     * 图片裁剪(固定尺寸/等比例)     * @param int $cropWidth 裁剪宽度     * @param int $cropHeight 裁剪高度     * @param string $mode 裁剪模式:center(居中)、top_left(左上)     * @return $this     */    public function crop(int $cropWidthint $cropHeightstring $mode 'center'): self    {        // 计算裁剪起始位置        $x 0;        $y 0;        if($mode == 'center') {            $x = ($this->width - $cropWidth) / 2;            $y = ($this->height - $cropHeight) / 2;            // 防止裁剪尺寸超过原图            $x $x 0 ? 0 : $x;            $y $y 0 ? 0 : $y;            $cropWidth $cropWidth $this->width ? $this->width : $cropWidth;            $cropHeight $cropHeight $this->height ? $this->height : $cropHeight;        }        // 创建裁剪后的画布        $newImage imagecreatetruecolor($cropWidth$cropHeight);        if(!$newImage) {            throw new Exception('创建裁剪画布失败,可能内存不足');        }        // 优化:PNG透明背景增强处理(绝对防止黑底)        if($this->type == 'png') {            imagealphablending($newImagefalse);            imagesavealpha($newImagetrue);            // 填充完全透明的背景色            $transparent imagecolorallocatealpha($newImage000127);            imagefill($newImage00$transparent);        }        // 执行裁剪        $result imagecopyresampled(            $newImage$this->image,            00, (int)$x, (int)$y,            $cropWidth$cropHeight,            $cropWidth$cropHeight        );        if(!$result) {            throw new Exception('图片裁剪失败');        }        // 释放旧资源        imagedestroy($this->image);        $this->image = $newImage;        $this->width = $cropWidth;        $this->height = $cropHeight;        return $this;    }    /**     * 添加文字水印     * @param string $text 水印文字     * @param string $font 字体文件路径     * @param array $config 配置     * @return $this     */    public function addTextWatermark(string $textstring $fontarray $config = []): self    {        // 检查字体文件是否存在(路径安全校验)        $realFontPath realpath($font);        if($realFontPath === false || strpos($realFontPath$this->allowedRootDir) !== 0) {            throw new Exception('字体文件不存在或路径非法:' . $font);        }        $default = [            'size' => 12,            'color' => [180180180],            'position' => 'bottom_right',            'alpha' => 80        ];        $config array_merge($default$config);        // 创建水印颜色        $color imagecolorallocatealpha($this->image, $config['color'][0], $config['color'][1], $config['color'][2], $config['alpha']);        if($color === false) {            throw new Exception('创建水印颜色失败');        }        // 校验文字尺寸        $textBox imagettfbbox($config['size'], 0$realFontPath$text);        if($textBox === false) {            throw new Exception('获取文字尺寸失败(字体文件错误或文字为空)');        }        $textWidth $textBox[2] - $textBox[0];        $textHeight $textBox[7] - $textBox[1];        // 计算位置        switch($config['position']) {            case 'center':                $x = ($this->width - $textWidth) / 2;                $y = ($this->height + $textHeight) / 2;                break;            case 'bottom_right':            default:                $x $this->width - $textWidth 10;                $y $this->height - 10;                break;        }        // 添加文字水印        $result imagettftext($this->image, $config['size'], 0$x$y$color$realFontPath$text);        if($result === false) {            throw new Exception('添加文字水印失败');        }        return $this;    }    /**     * 添加图片水印     * @param string $waterPath 水印图片路径     * @param array $config 配置     * @return $this     */    public function addImageWatermark(string $waterPatharray $config = []): self    {        // 路径安全校验        $realWaterPath realpath($waterPath);        if($realWaterPath === false || strpos($realWaterPath$this->allowedRootDir) !== 0) {            throw new Exception('水印图片不存在或路径非法:' . $waterPath);        }        $default = [            'position' => 'bottom_right',            'alpha' => 50,            'scale' => 0.2        ];        $config array_merge($default$config);        // 获取水印图片信息        $waterInfo getimagesize($realWaterPath);        if(!$waterInfo) {            throw new Exception('无法识别水印图片格式');        }        $waterType strtolower(image_type_to_extension($waterInfo[2], false));        if(!$waterType) {            throw new Exception('不支持的水印格式:' . $waterInfo[2]);        }        // 创建水印资源        $waterImage null;        switch($waterType) {            case 'jpg':            case 'jpeg':                $waterImage imagecreatefromjpeg($realWaterPath);                break;            case 'png':                $waterImage imagecreatefrompng($realWaterPath);                break;            case 'gif':                $waterImage imagecreatefromgif($realWaterPath);                break;            default:                throw new Exception('不支持的水印格式:' . $waterType);        }        if(!$waterImage) {            throw new Exception('创建水印图片资源失败');        }        $waterWidth $waterInfo[0] * $config['scale'];        $waterHeight $waterInfo[1] * $config['scale'];        // 计算水印位置        switch($config['position']) {            case 'center':                $x = ($this->width - $waterWidth) / 2;                $y = ($this->height - $waterHeight) / 2;                break;            case 'bottom_right':            default:                $x $this->width - $waterWidth 10;                $y $this->height - $waterHeight 10;                break;        }        // 类型安全:强制转int        $waterWidthInt = (int)$waterWidth;        $waterHeightInt = (int)$waterHeight;        // 添加图片水印        $result imagecopymerge(            $this->image,             $waterImage            (int)$x            (int)$y            0            0            $waterWidthInt            $waterHeightInt            $config['alpha']        );        if($result === false) {            throw new Exception('添加图片水印失败');        }        imagedestroy($waterImage);        return $this;    }    /**     * 转换为WebP格式     * @return $this     */    public function toWebP(): self    {        if(!function_exists('imagewebp')) {            throw new Exception('当前PHP环境不支持WebP格式(GD库未编译WebP支持)');        }        $this->type = 'webp';        return $this;    }    /**     * 保存处理后的图片     * @param string $savePath 保存路径     * @return bool     */    public function save(string $savePath): bool    {        // 路径安全校验:确保保存路径在允许的根目录内        $realSaveDir realpath(dirname($savePath)) ?: dirname($savePath);        if(strpos($realSaveDir$this->allowedRootDir) !== 0) {            throw new Exception('非法保存路径:不允许保存到根目录外');        }        $dir dirname($savePath);        if(!is_dir($dir)) {            mkdir($dir0755true);        }        // 检查目录写入权限        if(!is_writable($dir)) {            throw new Exception('保存目录无写入权限:' . $dir);        }        // 执行保存        $result false;        switch($this->type) {            case 'jpg':            case 'jpeg':                $result imagejpeg($this->image, $savePath$this->quality ?? 80);                break;            case 'png':                $pngLevel 9 - (int)(($this->quality ?? 80) / 10);                $pngLevel max(0min(9$pngLevel));                $result imagepng($this->image, $savePath$pngLevel);                break;            case 'gif':                $result imagegif($this->image, $savePath);                break;            case 'webp':                $result imagewebp($this->image, $savePath$this->quality ?? 80);                break;            default:                throw new Exception('不支持的保存格式:' . $this->type);        }        if(!$result) {            throw new Exception('保存图片失败(路径无写入权限或格式错误)');        }        return $result;    }}
三、实战使用示例(直接套用)
1. 图片压缩(上传后自动压缩)
<?phptry {    $image new ImageHandler('./upload/original.jpg');    $image->compress(801000)->save('./upload/compress.jpg');    echo '压缩成功';catch(Exception $e) {    echo '错误:' . $e->getMessage();}
2. 图片添加文字水印
<?phptry {    $image new ImageHandler('./upload/pic.jpg');    $image->addTextWatermark('牛马精神支柱之PHP实战干货''./font/simhei.ttf', [        'size' => 16,        'color' => [255,0,0],        'position' => 'center'    ])->save('./upload/water.jpg');catch(Exception $e) {    echo $e->getMessage();}
3. 生成头像裁剪(200×200)
<?phptry {    $image new ImageHandler('./upload/avatar.jpg');    $image->crop(200200)->save('./upload/avatar_200.jpg');catch(Exception $e) {    echo $e->getMessage();}
4. 转为 WebP 格式
<?phptry {    $image new ImageHandler('./upload/pic.jpg');    $image->compress(80)->toWebP()->save('./upload/pic.webp');    echo 'WebP 转换完成';catch(Exception $e) {    echo $e->getMessage();}
四、线上使用注意事项
  • 字体文件:文字水印需要.ttf字体,放入项目并配置正确路径;
  • PNG 透明:已内置防黑底处理,透明图不会再变黑;
  • 写入权限:上传 / 保存目录必须给 PHP 写入权限(755);
  • 安全限制:类自带路径安全校验,防止用户传入非法路径;
  • 批量处理:大量图片建议用异步任务,避免超时。

关注我,后续我会继续分享:PHP 开发规范、框架实战、架构思路、运维技巧、效率工具。关注我,每天 3 分钟,提升开发效率。

欢迎在留言区告诉我:你项目里图片处理是自己写代码,还是用第三方插件?遇到过 PNG 透明变黑、WebP 兼容这类坑吗?

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-03-27 17:23:28 HTTP/2.0 GET : https://f.mffb.com.cn/a/480089.html
  2. 运行时间 : 0.266243s [ 吞吐率:3.76req/s ] 内存消耗:4,669.39kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=18585cc2324cda80267e3d3e56eaf918
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000637s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000555s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.006909s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.006406s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000542s ]
  6. SELECT * FROM `set` [ RunTime:0.000426s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000543s ]
  8. SELECT * FROM `article` WHERE `id` = 480089 LIMIT 1 [ RunTime:0.014577s ]
  9. UPDATE `article` SET `lasttime` = 1774603409 WHERE `id` = 480089 [ RunTime:0.004430s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 64 LIMIT 1 [ RunTime:0.004626s ]
  11. SELECT * FROM `article` WHERE `id` < 480089 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.004564s ]
  12. SELECT * FROM `article` WHERE `id` > 480089 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.001300s ]
  13. SELECT * FROM `article` WHERE `id` < 480089 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.025485s ]
  14. SELECT * FROM `article` WHERE `id` < 480089 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.018303s ]
  15. SELECT * FROM `article` WHERE `id` < 480089 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.030477s ]
0.267915s