php.jpg 使用php生成验证码时报错!

Call to undefined function Intervention\Image\Gd\imagettfbbox()

先看下是否安装gd

brew info gd

gd: stable 2.2.5 (bottled), HEAD

Graphics library to dynamically manipulate images

https://libgd.github.io/

Not installed

From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/gd.rb

==> Dependencies

Required: fontconfig ✔, freetype ✔, jpeg ✔, libpng ✔, libtiff ✔, webp ✔

==> Options

--HEAD

	Install HEAD version

发现没有,安装gd

brew install gd

重启php后发现还是不行,卸载php重新安装

brew install [email protected] --with-httpd --with-freetype

报错,发现brew不支持自定义编译参数了 然后卸载[email protected]安装[email protected] 还是不行,, php -version 发现版本还是7.1,这时候豁然开朗,我原来一直用的是mac自带的php

mv /usr/bin/php php.bak

echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc

echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc

卸载(其实是改了个名字)自带php,把brew安装的php加到path 这回验证码终于出来了 php-verify-code.png