PHP php@7.0 的扩展 mosquitto 安装来自自制软件

PHP extension mosquitto installation for php@7.0 from homebrew

OS:MacOS High Sierra 10.13.5

我的 php 是通过自制程序链接的:

which php
/usr/local/bin/php

php -v
PHP 7.0.31 (cli) (built: Jul 19 2018 23:41:03) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
    with Zend OPcache v7.0.31, Copyright (c) 1999-2017, by Zend Technologies

我有基于 php 的项目,我正在尝试通过 composer install 提取依赖项,我得到:

 Your requirements could not be resolved to an installable set of packages.

 Problem 1
    - Installation request for pds/solace v1.0.1 -> satisfiable by pds/solace[v1.0.1].
    - pds/solace v1.0.1 requires ext-mosquitto * -> the requested PHP extension mosquitto is missing from your system.

  To enable extensions, verify that they are enabled in your .ini files:
    - /usr/local/etc/php/7.0/php.ini
    - /usr/local/etc/php/7.0/conf.d/ext-opcache.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

所以我正在尝试使用

通过 Pecl 安装扩展
pecl install Mosquitto-alpha

然后我得到

downloading Mosquitto-0.4.0.tgz ...
Starting to download Mosquitto-0.4.0.tgz (23,804 bytes)
........done: 23,804 bytes
5 source files, building
running: phpize
Configuring for:
PHP Api Version:         20151012
Zend Module Api No:      20151012
Zend Extension Api No:   320151012
Please provide the prefix of the libmosquitto installation [autodetect] : 
building in /private/tmp/pear/temp/pear-build-skalashnikovtgyrLB/Mosquitto-0.4.0
running: /private/tmp/pear/temp/Mosquitto/configure --with-php-config=/usr/local/opt/php@7.0/bin/php-config --with-mosquitto
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-darwin17.6.0
checking host system type... x86_64-apple-darwin17.6.0
checking target system type... x86_64-apple-darwin17.6.0
checking for PHP prefix... /usr/local/Cellar/php@7.0/7.0.31
checking for PHP includes... -I/usr/local/Cellar/php@7.0/7.0.31/include/php -I/usr/local/Cellar/php@7.0/7.0.31/include/php/main -I/usr/local/Cellar/php@7.0/7.0.31/include/php/TSRM -I/usr/local/Cellar/php@7.0/7.0.31/include/php/Zend -I/usr/local/Cellar/php@7.0/7.0.31/include/php/ext -I/usr/local/Cellar/php@7.0/7.0.31/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/Cellar/php@7.0/7.0.31/pecl/20151012
checking for PHP installed headers prefix... /usr/local/Cellar/php@7.0/7.0.31/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 mosquitto support... yes, shared
checking for mosquitto files in default path... not found
configure: error: Please reinstall the mosquitto distribution
ERROR: `/private/tmp/pear/temp/Mosquitto/configure --with-php-config=/usr/local/opt/php@7.0/bin/php-config --with-mosquitto' failed

我找到了解决方案..必须执行:

brew install mosquitto

安装了 mosquitto 和所有依赖项

==> Installing dependencies for mosquitto: c-ares, openssl, libev, libuv, libevent, libwebsockets

...

==> Installing mosquitto

==> Summary /usr/local/Cellar/mosquitto/1.4.14_2: 33 files, 629.9KB

然后执行

pecl install Mosquitto-alpha

成功安装了 php 库并链接了它

downloading Mosquitto-0.4.0.tgz ... Starting to download Mosquitto-0.4.0.tgz (23,804 bytes) ........done: 23,804 bytes

...

Build process completed successfully

Installing '/usr/local/Cellar/php@7.0/7.0.31/pecl/20151012/mosquitto.so'

install ok: channel://pecl.php.net/Mosquitto-0.4.0

Extension mosquitto enabled in php.ini