Skip to content

# 依赖关系图表 ​

在编译 PHP 时，每个扩展、库都有依赖关系，这些依赖关系可能是必需的，也可能是可选的。在编译 PHP 时，可以选择是否包含这些可选的依赖关系。

例如，在 Linux 下编译 `gd` 扩展时，会强制编译 `zlib,libpng` 库和 `zlib` 扩展，而 `libavif,libwebp,libjpeg,freetype` 库都是可选的库，默认不会编译，除非通过 `--with-libs=avif,webp,jpeg,freetype` 选项指定。

- 对于可选扩展（扩展的可选特性），需手动在编译时指定，例如启用 Redis 的 igbinary 支持：`bin/spc build redis,igbinary`。
- 对于可选库，需通过 `--with-libs=XXX` 选项编译指定。
- 如果想启用所有的可选扩展，可以使用 `bin/spc build redis --with-suggested-exts` 参数。
- 如果想启用所有的可选库，可以使用 `--with-suggested-libs` 参数。

## 扩展的依赖图 ​

### Linux ​

Extension Name | Required Extensions | Suggested Extensions | Required Libraries | Suggested Libraries
--- | --- | --- | --- | ---
amqp |  |  | librabbitmq |
bz2 |  |  | bzip2 |
curl |  |  | curl |
dba |  |  |  | qdbm
dom |  |  | libxml2 zlib |
event | openssl | sockets | libevent |
ftp |  |  |  | openssl
gd | zlib |  | zlib libpng | libavif libwebp libjpeg freetype
gettext |  |  | gettext |
gmp |  |  | gmp |
gmssl |  |  | gmssl |
grpc |  |  | grpc |
iconv |  |  | libiconv |
igbinary |  | session apcu |  |
imagick |  |  | imagemagick |
imap |  | openssl | imap |
intl |  |  | icu |
ldap |  | openssl | ldap | gmp libsodium
libxml | xml |  |  |
mbregex | mbstring |  | onig |
memcache | session |  | zlib |
mongodb |  |  |  | icu openssl zstd zlib
mysqli | mysqlnd |  |  |
mysqlnd |  |  | zlib |
openssl | zlib |  | openssl zlib |
password-argon2 |  |  | libargon2 |
pdo_mysql | pdo mysqlnd |  |  |
pdo_pgsql | pdo pgsql |  | postgresql |
pdo_sqlite | pdo sqlite3 |  | sqlite |
pdo_sqlsrv | pdo sqlsrv |  |  |
pgsql |  |  | postgresql |
phar | zlib |  |  |
rdkafka |  |  | librdkafka |
readline |  |  | readline |
redis |  | session igbinary |  | zstd liblz4
simplexml |  |  | libxml2 |
snappy |  | apcu | snappy |
soap |  |  | libxml2 |
sodium |  |  | libsodium |
spx |  |  | zlib |
sqlite3 |  |  | sqlite |
sqlsrv | pcntl |  | unixodbc |
ssh2 |  |  | libssh2 |
swoole | openssl curl | swoole-hook-pgsql swoole-hook-mysql swoole-hook-sqlite | libcares brotli nghttp2 zlib |
swoole-hook-mysql | mysqlnd pdo pdo_mysql | mysqli |  |
swoole-hook-pgsql | pgsql pdo |  |  |
swoole-hook-sqlite | sqlite3 pdo |  |  |
swow |  | openssl curl |  | openssl curl
tidy |  |  | tidy |
uuid |  |  | libuuid |
uv | sockets |  | libuv |
xhprof | ctype |  |  |
xlswriter | zlib zip |  |  | openssl
xml |  |  | libxml2 |
xmlreader |  |  | libxml2 |
xmlwriter |  |  | libxml2 |
xsl | xml dom |  | libxslt |
yac | igbinary |  |  |
yaml |  |  | libyaml |
zip |  |  | libzip |
zlib |  |  | zlib |
zstd |  |  | zstd |

### macOS ​

Extension Name | Required Extensions | Suggested Extensions | Required Libraries | Suggested Libraries
--- | --- | --- | --- | ---
amqp |  |  | librabbitmq |
bz2 |  |  | bzip2 |
curl |  |  | curl |
dba |  |  |  | qdbm
dom |  |  | libxml2 zlib |
event | openssl | sockets | libevent |
ffi |  |  | libffi |
ftp |  |  |  | openssl
gd | zlib |  | zlib libpng | libavif libwebp libjpeg freetype
gettext |  |  | gettext |
glfw |  |  | glfw |
gmp |  |  | gmp |
gmssl |  |  | gmssl |
grpc |  |  | grpc |
iconv |  |  | libiconv |
igbinary |  | session apcu |  |
imagick |  |  | imagemagick |
imap |  | openssl | imap |
intl |  |  | icu |
ldap |  | openssl | ldap | gmp libsodium
libxml | xml |  |  |
mbregex | mbstring |  | onig |
memcache | session |  | zlib |
memcached | session zlib |  | libmemcached |
mongodb |  |  |  | icu openssl zstd zlib
mysqli | mysqlnd |  |  |
mysqlnd |  |  | zlib |
openssl | zlib |  | openssl zlib |
password-argon2 |  |  | libargon2 |
pdo_mysql | pdo mysqlnd |  |  |
pdo_pgsql | pdo pgsql |  | postgresql |
pdo_sqlite | pdo sqlite3 |  | sqlite |
pdo_sqlsrv | pdo sqlsrv |  |  |
pgsql |  |  | postgresql |
phar | zlib |  |  |
rdkafka |  |  | librdkafka |
readline |  |  | readline |
redis |  | session igbinary |  | zstd liblz4
simplexml |  |  | libxml2 |
snappy |  | apcu | snappy |
soap |  |  | libxml2 |
sodium |  |  | libsodium |
spx |  |  | zlib |
sqlite3 |  |  | sqlite |
sqlsrv |  |  | unixodbc |
ssh2 |  |  | libssh2 |
swoole | openssl curl | swoole-hook-pgsql swoole-hook-mysql swoole-hook-sqlite | libcares brotli nghttp2 zlib |
swoole-hook-mysql | mysqlnd pdo pdo_mysql | mysqli |  |
swoole-hook-pgsql | pgsql pdo |  |  |
swoole-hook-sqlite | sqlite3 pdo |  |  |
swow |  | openssl curl |  | openssl curl
tidy |  |  | tidy |
uuid |  |  | libuuid |
uv | sockets |  | libuv |
xhprof | ctype |  |  |
xlswriter | zlib zip |  |  | openssl
xml |  |  | libxml2 |
xmlreader |  |  | libxml2 |
xmlwriter |  |  | libxml2 |
xsl | xml dom |  | libxslt |
yac | igbinary |  |  |
yaml |  |  | libyaml |
zip |  |  | libzip |
zlib |  |  | zlib |
zstd |  |  | zstd |

### Windows ​

Extension Name | Required Extensions | Suggested Extensions | Required Libraries | Suggested Libraries
--- | --- | --- | --- | ---
amqp | openssl |  | librabbitmq |
bz2 |  |  | bzip2 |
curl | zlib openssl |  | curl |
dba |  |  |  | qdbm
dom | xml |  | libxml2 zlib |
ffi |  |  | libffi-win |
ftp |  |  |  | openssl
gd | zlib |  | zlib libpng | libavif libwebp libjpeg freetype
gmssl |  |  | gmssl |
iconv |  |  | libiconv-win |
igbinary |  | session apcu |  |
libxml | xml |  |  |
mbregex | mbstring |  | onig |
mysqli | mysqlnd |  |  |
mysqlnd |  |  | zlib |
openssl | zlib |  | openssl zlib |
parallel |  |  | pthreads4w |
pdo_mysql | pdo mysqlnd |  |  |
pdo_sqlite | pdo sqlite3 |  | sqlite |
pdo_sqlsrv | pdo sqlsrv |  |  |
phar | zlib |  |  |
redis |  | session igbinary |  |
simplexml | xml |  | libxml2 |
soap | xml |  | libxml2 |
sqlite3 |  |  | sqlite |
ssh2 | openssl zlib |  | libssh2 |
swow |  | openssl curl |  | openssl curl
xml | iconv |  | libxml2 |
xmlreader | xml dom |  | libxml2 |
xmlwriter | xml |  | libxml2 |
yaml |  |  | libyaml |
zip | zlib bz2 |  | libzip zlib bzip2 xz |
zlib |  |  | zlib |

### FreeBSD ​

Extension Name | Required Extensions | Suggested Extensions | Required Libraries | Suggested Libraries
--- | --- | --- | --- | ---
bz2 |  |  | bzip2 |
curl |  |  | curl |
dba |  |  |  | qdbm
ftp |  |  |  | openssl
mbregex | mbstring |  | onig |
mysqli | mysqlnd |  |  |
mysqlnd |  |  | zlib |
openssl | zlib |  | openssl zlib |
pdo_mysql | pdo mysqlnd |  |  |
phar | zlib |  |  |
zlib |  |  | zlib |

## 库的依赖表 ​

### Linux ​

Library Name | Required Libraries | Suggested Libraries
--- | --- | ---
curl | openssl zlib | libssh2 brotli nghttp2 zstd libcares
freetype | zlib | libpng bzip2 brotli
gettext | libiconv | ncurses libxml2
grpc | zlib openssl |
imagemagick | zlib libpng libjpeg libwebp freetype libtiff libheif | zstd xz bzip2 libzip libxml2
imap |  | openssl
ldap | openssl zlib gmp libsodium |
libevent | openssl |
libheif | libde265 libwebp libaom zlib brotli |
libpng | zlib |
librabbitmq | openssl |
librdkafka |  | zstd
libssh2 | openssl | zlib
libtiff | zlib libjpeg |
libxml2 | libiconv | xz icu zlib
libxslt | libxml2 |
libzip | zlib | bzip2 xz zstd openssl
nghttp2 | zlib openssl | libxml2
openssl | zlib |
postgresql | libiconv libxml2 openssl zlib readline | icu libxslt ldap zstd
readline | ncurses |
snappy | zlib |
unixodbc | libiconv |
xz | libiconv |

### macOS ​

Library Name | Required Libraries | Suggested Libraries
--- | --- | ---
curl | openssl zlib | libssh2 brotli nghttp2 zstd libcares
freetype | zlib | libpng bzip2 brotli
gettext | libiconv | ncurses libxml2
grpc | zlib openssl |
imagemagick | zlib libpng libjpeg libwebp freetype libtiff libheif | zstd xz bzip2 libzip libxml2
imap |  | openssl
ldap | openssl zlib gmp libsodium |
libevent | openssl |
libheif | libde265 libwebp libaom zlib brotli |
libpng | zlib |
librabbitmq | openssl |
librdkafka |  | zstd
libssh2 | openssl | zlib
libtiff | zlib libjpeg |
libxml2 | libiconv | xz icu zlib
libxslt | libxml2 |
libzip | zlib | bzip2 xz zstd openssl
nghttp2 | zlib openssl | libxml2
openssl | zlib |
postgresql | libiconv libxml2 openssl zlib readline | icu libxslt ldap zstd
readline | ncurses |
snappy | zlib |
unixodbc | libiconv |
xz | libiconv |

### Windows ​

Library Name | Required Libraries | Suggested Libraries
--- | --- | ---
curl | openssl zlib libssh2 nghttp2 | brotli zstd
freetype | zlib | libpng bzip2 brotli
libjpeg |  | zlib
libpng | zlib |
librabbitmq | openssl |
libssh2 | openssl | zlib
libxml2 | libiconv-win | zlib
libzip | zlib bzip2 xz | zstd openssl
nghttp2 | zlib openssl | libxml2
openssl | zlib |

### FreeBSD ​

Library Name | Required Libraries | Suggested Libraries
--- | --- | ---
curl | openssl zlib | libssh2 brotli nghttp2 zstd libcares
openssl | zlib |