PHP Conference Japan 2024

安装

Linux 系统

为了使用这些函数,PHP 必须在编译时使用 --with-zip 配置选项以启用 ZIP 支持。

在 PHP 7.4.0 之前,libzip 与 PHP 捆绑在一起,要编译此扩展需要使用 --enable-zip 配置选项。从 PHP 7.3.0 起,不再建议与捆绑的 libzip 一起构建,但仍然可以通过使用 --without-libzip 配置选项来实现。

已添加 --with-libzip=DIR 配置选项以使用系统安装的 libzip。需要 libzip 0.11 版本,建议使用 0.11.2 或更高版本。

Windows

从 PHP 8.2.0 起,必须在 php.ini启用 php_zip.dll DLL。在此之前,该扩展是内置的。

通过 PECL 安装

有关安装此 PECL 扩展的信息,请参阅手册中题为安装 PECL 扩展的章节。其他信息,如新版本、下载、源文件、维护者信息和一个 CHANGELOG,可以在这里找到:» https://pecl.php.net/package/zip

添加注释

用户贡献的注释 3 条注释

21
Marcel
5 年前
编译此扩展用于 php 7.3 时出现错误

configure: error: Please reinstall the libzip distribution

您需要安装 'libzip' 包。

在 Dockerfile 中,您可以这样做

# 安装 zip

RUN apt-get update && \
apt-get install -y \
libzip-dev \
&& docker-php-ext-install zip
0
askertv at gmail dot com
9 个月前
解决 "No package 'libzip' found"

$ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib64/pkgconfig/

$ ./configure \
...
--with-zip \
...

配置成功

$ make && make install
-1
askertv at gmail dot com
9 个月前
找不到包 'libzip'

从源码安装 PHP

./configure \
--prefix=/usr/local/php-7.4.5 \
--disable-debug \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-inline-optimization \
--enable-ftp \
--enable-xml \
--with-libdir=/usr/lib64 \
--with-curl \
--with-iconv \
--with-gettext \
--with-mysqli \
--enable-pdo \
--with-pdo-mysql \
--with-zlib \
--with-zlib-dir=/usr/lib \
--srcdir=/usr/local/src/php-7.4.5 \
--enable-sockets \
--enable-soap \
--with-openssl \
--enable-gd \
--with-jpeg \
--with-xpm \
--with-freetype \
--with-zip \
--with-libzip=/usr/local/lib64/ \
ONIG_LIBS=/usr/lib64

checking for zip archive read/write support... yes
checking for libzip >= 0.11... no
configure: error: Package requirements (libzip >= 0.11) were not met

找不到包 'libzip'

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables LIBZIP_CFLAGS
and LIBZIP_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

从源码安装 libzip-1.10.1

make install
[ 50%] Built target zip
[ 94%] Built target man
[ 96%] Built target zipcmp
[ 96%] Built target zipmerge
[ 98%] Built target ziptool
[ 98%] Built target add-compressed-data
[ 98%] Built target autoclose-archive
[100%] Built target in-memory
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/lib64/pkgconfig/libzip.pc
-- Installing: /usr/local/lib64/cmake/libzip/modules/FindNettle.cmake
-- Installing: /usr/local/lib64/cmake/libzip/modules/Findzstd.cmake
-- Installing: /usr/local/lib64/cmake/libzip/modules/FindMbedTLS.cmake
-- Installing: /usr/local/include/zipconf.h
-- Installing: /usr/local/lib64/cmake/libzip/libzip-config.cmake
-- Installing: /usr/local/lib64/cmake/libzip/libzip-config-version.cmake
-- Installing: /usr/local/lib64/cmake/libzip/libzip-targets.cmake
-- Installing: /usr/local/lib64/cmake/libzip/libzip-targets-noconfig.cmake
-- Installing: /usr/local/lib64/libzip.so.5.5
-- Up-to-date: /usr/local/lib64/libzip.so.5
-- Up-to-date: /usr/local/lib64/libzip.so
-- Installing: /usr/local/include/zip.h
-- Installing: /usr/local/share/man/man3/ZIP_SOURCE_GET_ARGS.3
...
...
-- Installing: /usr/local/bin/zipcmp
-- Set runtime path of "/usr/local/bin/zipcmp" to ""
-- Installing: /usr/local/bin/zipmerge
-- Set runtime path of "/usr/local/bin/zipmerge" to ""
-- Installing: /usr/local/bin/ziptool
-- Set runtime path of "/usr/local/bin/ziptool" to ""

操作系统: RedHat-7.9
To Top