Class 'ZipArchive' not found MAC

MAC 系統(tǒng)升級(jí)到 10.15.1 后,PHP擴(kuò)展環(huán)境失效赖晶。報(bào)錯(cuò) Class 'ZipArchive' not found


1 安裝 pecl

1)執(zhí)行? pecl version

報(bào)錯(cuò):? pecl: command not found

2) 安裝? pecl

1)curl -O https://pear.php.net/go-pear.phar

2)sudo php -d detect_unicode=0 go-pear.phar

3)輸入: 1

4)輸入: 4

5)回車 (可能多次回車)

3) 執(zhí)行 pecl version

返回如下:

PEAR Version: 1.10.9

PHP Version: 7.3.9

Zend Engine Version: 3.3.9

Running on: Darwin jiaweideMacBook-Pro.local 19.0.0 Darwin Kernel Version 19.0.0: Thu Oct 17 16:17:15 PDT 2019; root:xnu-6153.41.3~29/RELEASE_X86_64 x86_64

2 安裝zip

1) pecl search zip

2) sudo pecl install zip

downloading zip-1.15.5.tgz ...Starting to download zip-1.15.5.tgz (286,794 bytes)............................................................done: 286,794 bytes14 source files, buildingrunning: phpizeConfiguring for:PHP Api Version:? ? ? ? 20180731Zend Module Api No:? ? ? 20180731Zend Extension Api No:? 320180731Cannot find autoconf. Please check your autoconf installation and the$PHP_AUTOCONF environment variable. Then, rerun this script.ERROR: `phpize' failed如果 失敗 按照提示 安裝 autoconf

3) brew install autoconf

4) sudo pecl install zip

downloading zip-1.15.5.tgz ...

Starting to download zip-1.15.5.tgz (286,794 bytes)

............................................................done: 286,794 bytes

14 source files, building

running: phpize

Configuring for:

PHP Api Version:? ? ? ? 20180731

Zend Module Api No:? ? ? 20180731

Zend Extension Api No:? 320180731

building in /private/tmp/pear/install/pear-build-rootTVh4R1/zip-1.15.5

running: /private/tmp/pear/install/zip/configure --with-php-config=/usr/bin/php-config

checking for grep that handles long lines and -e... /usr/bin/grep

checking for egrep... /usr/bin/grep -E

checking for a sed that does not truncate output... /usr/bin/sed

checking for cc... cc

checking whether the C compiler works... yes

checking for C compiler default output file name... a.out

checking for suffix of executables...

checking whether we are cross compiling... no

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether cc accepts -g... yes

checking for cc option to accept ISO C89... none needed

checking how to run the C preprocessor... cc -E

checking for icc... no

checking for suncc... no

checking whether cc understands -c and -o together... yes

checking for system library directory... lib

checking if compiler supports -R... no

checking if compiler supports -Wl,-rpath,... yes

checking build system type... x86_64-apple-darwin19.0.0

checking host system type... x86_64-apple-darwin19.0.0

checking target system type... x86_64-apple-darwin19.0.0

checking for PHP prefix... /usr

checking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib

checking for PHP extension directory... /usr/lib/php/extensions/no-debug-non-zts-20180731

checking for PHP installed headers prefix... /usr/include/php

checking if debug is enabled... no

checking if zts is enabled... no

checking for re2c... no

configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.

checking for gawk... no

checking for nawk... no

checking for awk... awk

checking if awk is broken... no

checking for zip archive read/writesupport... yes, shared

checking libzip... yes

checking PHP version... 7.3

checking for pkg-config... /usr/local/bin/pkg-config

checking for libzip... from pkgconfig: version 1.5.2 found in /usr/local/Cellar/libzip/1.5.2/lib

checking for zip_open in -lzip... yes

checking for zip_file_set_encryption in -lzip... yes

checking for zip_libzip_version in -lzip... yes

checking for ld used by cc... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld

checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... no

checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld option to reload object files... -r

checking for BSD-compatible nm... /usr/bin/nm -B

checking whether ln -s works... yes

checking how to recognize dependent libraries... pass_all

checking for ANSI C header files... yes

checking for sys/types.h... yes

checking for sys/stat.h... yes

checking for stdlib.h... yes

checking for string.h... yes

checking for memory.h... yes

checking for strings.h... yes

checking for inttypes.h... yes

checking for stdint.h... yes

checking for unistd.h... yes

checking dlfcn.h usability... yes

checking dlfcn.h presence... yes

checking for dlfcn.h... yes

checking the maximum length of command line arguments... 196608

checking command to parse /usr/bin/nm -B output from cc object... ok

checking for objdir... .libs

checking for ar... ar

checking for ranlib... ranlib

checking for strip... strip

checking for dsymutil... dsymutil

checking for nmedit... nmedit

checking for -single_module linker flag... yes

checking for -exported_symbols_list linker flag... yes

checking if cc supports -fno-rtti -fno-exceptions... yes

checking for cc option to produce PIC... -fno-common

checking if cc PIC flag -fno-common works... yes

checking if cc static flag -static works... no

checking if cc supports -c -o file.o... yes

checking whether the cc linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes

checking dynamic linker characteristics... darwin19.0.0 dyld

checking how to hardcode library paths into programs... immediate

checking whether stripping libraries is possible... yes

checking if libtool supports shared libraries... yes

checking whether to build shared libraries... yes

checking whether to build static libraries... no

creating libtool

appending configuration tag "CXX" to libtool

configure: creating ./config.status

config.status: creating config.h

running: make

/bin/sh /private/tmp/pear/install/pear-build-rootTVh4R1/zip-1.15.5/libtool --mode=compile cc -I/usr/local/Cellar/libzip/1.5.2/include -I. -I/private/tmp/pear/install/zip -DPHP_ATOM_INC -I/private/tmp/pear/install/pear-build-rootTVh4R1/zip-1.15.5/include -I/private/tmp/pear/install/pear-build-rootTVh4R1/zip-1.15.5/main -I/private/tmp/pear/install/zip -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/private/tmp/pear/install/zip/php73? -DHAVE_CONFIG_H? -g -O2? -c /private/tmp/pear/install/zip/php73/php_zip.c -o php73/php_zip.lo

mkdir php73/.libs

cc -I/usr/local/Cellar/libzip/1.5.2/include -I. -I/private/tmp/pear/install/zip -DPHP_ATOM_INC -I/private/tmp/pear/install/pear-build-rootTVh4R1/zip-1.15.5/include -I/private/tmp/pear/install/pear-build-rootTVh4R1/zip-1.15.5/main -I/private/tmp/pear/install/zip -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/private/tmp/pear/install/zip/php73 -DHAVE_CONFIG_H -g -O2 -c /private/tmp/pear/install/zip/php73/php_zip.c? -fno-common -DPIC -o php73/.libs/php_zip.o

/bin/sh /private/tmp/pear/install/pear-build-rootTVh4R1/zip-1.15.5/libtool --mode=compile cc -I/usr/local/Cellar/libzip/1.5.2/include -I. -I/private/tmp/pear/install/zip -DPHP_ATOM_INC -I/private/tmp/pear/install/pear-build-rootTVh4R1/zip-1.15.5/include -I/private/tmp/pear/install/pear-build-rootTVh4R1/zip-1.15.5/main -I/private/tmp/pear/install/zip -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/private/tmp/pear/install/zip/php73? -DHAVE_CONFIG_H? -g -O2? -c /private/tmp/pear/install/zip/php73/zip_stream.c -o php73/zip_stream.lo

cc -I/usr/local/Cellar/libzip/1.5.2/include -I. -I/private/tmp/pear/install/zip -DPHP_ATOM_INC -I/private/tmp/pear/install/pear-build-rootTVh4R1/zip-1.15.5/include -I/private/tmp/pear/install/pear-build-rootTVh4R1/zip-1.15.5/main -I/private/tmp/pear/install/zip -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/private/tmp/pear/install/zip/php73 -DHAVE_CONFIG_H -g -O2 -c /private/tmp/pear/install/zip/php73/zip_stream.c? -fno-common -DPIC -o php73/.libs/zip_stream.o

/bin/sh /private/tmp/pear/install/pear-build-rootTVh4R1/zip-1.15.5/libtool --mode=link cc -DPHP_ATOM_INC -I/private/tmp/pear/install/pear-build-rootTVh4R1/zip-1.15.5/include -I/private/tmp/pear/install/pear-build-rootTVh4R1/zip-1.15.5/main -I/private/tmp/pear/install/zip -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/private/tmp/pear/install/zip/php73? -DHAVE_CONFIG_H? -g -O2? ? -o zip.la -export-dynamic -avoid-version -prefer-pic -module -rpath /private/tmp/pear/install/pear-build-rootTVh4R1/zip-1.15.5/modules? php73/php_zip.lo php73/zip_stream.lo -Wl,-rpath,/usr/local/Cellar/libzip/1.5.2/lib -L/usr/local/Cellar/libzip/1.5.2/lib -lzip

mkdir .libs

cc ${wl}-flat_namespace ${wl}-undefined ${wl}suppress -o .libs/zip.so -bundle? php73/.libs/php_zip.o php73/.libs/zip_stream.o? -L/usr/local/Cellar/libzip/1.5.2/lib -lzip? -Wl,-rpath -Wl,/usr/local/Cellar/libzip/1.5.2/lib

dsymutil .libs/zip.so || :

creating zip.la

(cd .libs && rm -f zip.la && ln -s ../zip.la zip.la)

/bin/sh /private/tmp/pear/install/pear-build-rootTVh4R1/zip-1.15.5/libtool --mode=install cp ./zip.la /private/tmp/pear/install/pear-build-rootTVh4R1/zip-1.15.5/modules

cp ./.libs/zip.so /private/tmp/pear/install/pear-build-rootTVh4R1/zip-1.15.5/modules/zip.so

cp ./.libs/zip.lai /private/tmp/pear/install/pear-build-rootTVh4R1/zip-1.15.5/modules/zip.la

----------------------------------------------------------------------

Libraries have been installed in:

? /private/tmp/pear/install/pear-build-rootTVh4R1/zip-1.15.5/modules

If you ever happen to want to link against installed libraries

in a given directory, LIBDIR, you must either use libtool, and

specify the full pathname of the library, or use the `-LLIBDIR'

flag during linking and do at least one of the following:

? - add LIBDIR to the `DYLD_LIBRARY_PATH' environment variable

? ? during execution

See any operating system documentation about shared libraries for

more information, such as the ld(1) and ld.so(8) manual pages.

----------------------------------------------------------------------

Build complete.

Don't forget to run 'make test'.

running: make INSTALL_ROOT="/private/tmp/pear/install/pear-build-rootTVh4R1/install-zip-1.15.5" install

Installing shared extensions:? ? /private/tmp/pear/install/pear-build-rootTVh4R1/install-zip-1.15.5/usr/lib/php/extensions/no-debug-non-zts-20180731/

running: find "/private/tmp/pear/install/pear-build-rootTVh4R1/install-zip-1.15.5" | xargs ls -dils

8609468174? 0 drwxr-xr-x? 3 root? wheel? ? 96 11 16 08:49 /private/tmp/pear/install/pear-build-rootTVh4R1/install-zip-1.15.5

8609468575? 0 drwxr-xr-x? 3 root? wheel? ? 96 11 16 08:49 /private/tmp/pear/install/pear-build-rootTVh4R1/install-zip-1.15.5/usr

8609468576? 0 drwxr-xr-x? 3 root? wheel? ? 96 11 16 08:49 /private/tmp/pear/install/pear-build-rootTVh4R1/install-zip-1.15.5/usr/lib

8609468577? 0 drwxr-xr-x? 3 root? wheel? ? 96 11 16 08:49 /private/tmp/pear/install/pear-build-rootTVh4R1/install-zip-1.15.5/usr/lib/php

8609468578? 0 drwxr-xr-x? 3 root? wheel? ? 96 11 16 08:49 /private/tmp/pear/install/pear-build-rootTVh4R1/install-zip-1.15.5/usr/lib/php/extensions

8609468579? 0 drwxr-xr-x? 3 root? wheel? ? 96 11 16 08:49 /private/tmp/pear/install/pear-build-rootTVh4R1/install-zip-1.15.5/usr/lib/php/extensions/no-debug-non-zts-20180731

8609468580 144 -rwxr-xr-x? 1 root? wheel? 70860 11 16 08:49 /private/tmp/pear/install/pear-build-rootTVh4R1/install-zip-1.15.5/usr/lib/php/extensions/no-debug-non-zts-20180731/zip.so

Build process completed successfully

Installing '/usr/lib/php/extensions/no-debug-non-zts-20180731/zip.so'

install ok: channel://pecl.php.net/zip-1.15.5

configuration option "php_ini" is not set to php.ini location

You should add "extension=zip.so" to php.ini

3 配置 php.ini

0) vi /private/etc/php.ini

如果報(bào)錯(cuò)减宣,執(zhí)行下面的操作(因?yàn)閙ac 本身 在/private/etc/沒有 php.ini ,可以 拷貝 /private/etc/php.ini.default? )

1) sudo cp /private/etc/php.ini.default /private/etc/php.ini

2) cd /private/etc/

3) chmod o+w php.ini

4) vi php.ini

5) Shit+G 進(jìn)入文件末尾惨篱, 輸入:i 進(jìn)入編輯模式

6) 拷貝 extension=zip.so固翰;

7) :wq

4 執(zhí)行 php -m 查看擴(kuò)展



補(bǔ)充:

1)忘了可能哪一步會(huì)報(bào)錯(cuò), zlib 版本過低堂污, 如果報(bào)錯(cuò)家肯,執(zhí)行 brew zlib

2) brew 建議 update 一次,可能需要1-2個(gè)小時(shí)盟猖,建議升級(jí)讨衣。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市式镐,隨后出現(xiàn)的幾起案子反镇,更是在濱河造成了極大的恐慌,老刑警劉巖娘汞,帶你破解...
    沈念sama閱讀 219,110評(píng)論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件歹茶,死亡現(xiàn)場離奇詭異,居然都是意外死亡你弦,警方通過查閱死者的電腦和手機(jī)惊豺,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,443評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來禽作,“玉大人尸昧,你說我怎么就攤上這事】醭ィ” “怎么了烹俗?”我有些...
    開封第一講書人閱讀 165,474評(píng)論 0 356
  • 文/不壞的土叔 我叫張陵,是天一觀的道長萍程。 經(jīng)常有香客問我幢妄,道長,這世上最難降的妖魔是什么茫负? 我笑而不...
    開封第一講書人閱讀 58,881評(píng)論 1 295
  • 正文 為了忘掉前任蕉鸳,我火速辦了婚禮,結(jié)果婚禮上忍法,老公的妹妹穿的比我還像新娘置吓。我一直安慰自己,他們只是感情好缔赠,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,902評(píng)論 6 392
  • 文/花漫 我一把揭開白布衍锚。 她就那樣靜靜地躺著,像睡著了一般嗤堰。 火紅的嫁衣襯著肌膚如雪戴质。 梳的紋絲不亂的頭發(fā)上度宦,一...
    開封第一講書人閱讀 51,698評(píng)論 1 305
  • 那天,我揣著相機(jī)與錄音告匠,去河邊找鬼戈抄。 笑死,一個(gè)胖子當(dāng)著我的面吹牛后专,可吹牛的內(nèi)容都是我干的划鸽。 我是一名探鬼主播,決...
    沈念sama閱讀 40,418評(píng)論 3 419
  • 文/蒼蘭香墨 我猛地睜開眼戚哎,長吁一口氣:“原來是場噩夢(mèng)啊……” “哼裸诽!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起型凳,我...
    開封第一講書人閱讀 39,332評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤丈冬,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后甘畅,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體埂蕊,經(jīng)...
    沈念sama閱讀 45,796評(píng)論 1 316
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,968評(píng)論 3 337
  • 正文 我和宋清朗相戀三年疏唾,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了蓄氧。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,110評(píng)論 1 351
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡槐脏,死狀恐怖匀们,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情准给,我是刑警寧澤,帶...
    沈念sama閱讀 35,792評(píng)論 5 346
  • 正文 年R本政府宣布重抖,位于F島的核電站露氮,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏钟沛。R本人自食惡果不足惜畔规,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,455評(píng)論 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望恨统。 院中可真熱鬧叁扫,春花似錦、人聲如沸畜埋。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,003評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽悠鞍。三九已至对室,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背掩宜。 一陣腳步聲響...
    開封第一講書人閱讀 33,130評(píng)論 1 272
  • 我被黑心中介騙來泰國打工蔫骂, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人牺汤。 一個(gè)月前我還...
    沈念sama閱讀 48,348評(píng)論 3 373
  • 正文 我出身青樓辽旋,卻偏偏與公主長得像,于是被迫代替她去往敵國和親檐迟。 傳聞我的和親對(duì)象是個(gè)殘疾皇子补胚,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,047評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容