swoole / swoole-cli Goto Github PK
View Code? Open in Web Editor NEWSWOOLE-CLI is a php binary distribution composed swoole & php-core & cli & fpm and mostly of common extensions.
SWOOLE-CLI is a php binary distribution composed swoole & php-core & cli & fpm and mostly of common extensions.
php prepare.php \
--with-build-type=dev \
--with-dependency-graph=1 \
+apcu +ds +inotify \
--without-docker=1 \
--with-download-mirror-url=https://swoole-cli.jingjingxyk.com/
1,支持event和protobuf
2,如何构建指定版本swoole (比如我想构建swoole版本4.8.13的cli, 官方提供的包没有我需要的扩展)
protobuf扩展按如下添加成功
php prepare.php
--with-build-type=release
+protobuf
--with-download-mirror-url=https://swoole-cli.jingjingxyk.com/
支持oracle扩展和sqlserver扩展
I follow the README to build swoole-cli, and it performs really bad.
After some troubleshooting, I find that the build script didn't include -lmimalloc
.
可以把swoole-cli 三端独立出来放到官网供人下载 直接运行swoole-cli跑项目 很方便部署 都不需要下载docker了
办法一: 直接指定依赖库所在目录 。例如(--with-openssl=/usr/openssl
)
办法二: 使用 pkg-config
办法三: 上述两种办法混用,大部分情况是(办法一)比(办法二)优先级高
为啥会混用,因为一部分库未提供
pkg-config
配置。 比如bzip2
,iconv
,libgif
等
例子:构建 curl
package_name='zlib openssl libcares libbrotlicommon libbrotlidec libbrotlienc libzstd libnghttp2 libidn2'
CPPFLAGS="$(pkg-config --cflags-only-I --static $package_name)" \
LDFLAGS="$(pkg-config --libs-only-L --static $package_name)" \
LIBS="$(pkg-config --libs-only-l --static $package_name)" \
./configure --prefix=/usr/curl \
--enable-static \
--disable-shared \
--without-librtmp \
--disable-ldap \
--disable-rtsp \
--enable-http \
--enable-alt-svc \
--enable-hsts \
--enable-http-auth \
--enable-mime \
--enable-cookies \
--enable-doh \
--enable-threaded-resolver \
--enable-ipv6 \
--enable-proxy \
--enable-websockets \
--enable-get-easy-options \
--enable-file \
--enable-mqtt \
--enable-unix-sockets \
--enable-progress-meter \
--enable-optimize \
--with-zlib=/usr/zlib \
--with-openssl=/usr/openssl \
--enable-ares=/usr/cares \
--with-default-ssl-backend=openssl \
--with-libidn2 \
--with-nghttp2 \
--without-ngtcp2 \
--without-nghttp3
经过编译 PHP 其他版本发现:PHP 8 之前的版本 ,不支持 OPENSSL V3
能否添加protobuf扩展
在低于macOS 12下 使用swoole-cli 会提示swoole-cli是构建于macOS 12, 导致无法使用
例如 apcu、ffi 这些能力,我看默认都没打包进来。
version: v5.0.1 / current main
command:
./make.sh config
configure:27873: $? = 0
configure:30163: checking for GNU gettext support
configure:30200: result: no
configure:30892: checking for GNU MP support
configure:30929: result: yes
configure:31121: error: Unable to locate gmp.h
使用依赖库镜像地址
方式一:
php prepare.php +ds +inotify +apcu +protobuf --with-download-mirror-url=https://swoole-cli.jingjingxyk.com
方式二:
执行这个脚本, 原理: 自动下载
https://swoole-cli.jingjingxyk.com/all-archive.zip
sh sapi/download-box/download-box-get-archive-from-server.sh
方式三:
借助容器分发
sh sapi/download-box/download-box-get-archive-from-container.sh
# 容器分发原理介绍
container_id=$(docker create $IMAGE) # returns container ID
docker cp $container_id:/usr/share/nginx/html/extensions extensions
docker cp $container_id:/usr/share/nginx/html/libraries libraries
docker rm $container_id
构建依赖库镜像参考: https://github.com/swoole/swoole-cli/tree/main/sapi/download-box
multiple definition of `nghttp2_strerror'; 函数多重定义
与这里出现冲突 https://github.com/swoole/swoole-src/blob/master/thirdparty/nghttp2/nghttp2_helper.c
/usr/bin/ld: /usr/nghttp2/lib/libnghttp2.a(nghttp2_helper.o): in function `nghttp2_strerror':
/work/thirdparty/nghttp2/lib/nghttp2_helper.c:254: multiple definition of `nghttp2_strerror'; ext/swoole/thirdparty/nghttp2/nghttp2_helper.o:/work/ext/swoole/thirdparty/nghttp2/nghttp2_helper.c:35: first defined here
clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Makefile:295: bin/swoole-cli] Error 1
解压以后执行如下命令:
sudo xattr -d com.apple.quarantine ./swoole-cli
这个扩展也是很第三方composer package 常见的依赖项, 例如一些支付sdk都会依赖该扩展
主仓库依赖库安装顺序 查看
# 查看依赖库和依赖库安装顺序
./make.sh list-library
# 查看各库 pkg-config 配置信息
./make.sh pkg-check
有兴趣的同志可以看参考以下:https://github.com/jingjingxyk/swoole-cli/pull/31/files
各依赖库构建过程放到:library_install_builder.php文件
库或者扩展的依赖关系简述: 用注释写在这个文件里library_builder.php
因为不能直观的看到依赖关系,因此诞生这个版本
macOS 反复验证:
发现 依赖库libxslt 默认启用 --with-python --with-crypto --with-profiler --with-plugins --with-debugger
其中 crypto 依赖 libunistring 、libgcrypt 进一步依赖 -framework SystemConfiguration
根源: -lintl -Wl,-framework -Wl,CoreFoundation
gettext库包含intl
coreutils库包含libunistring
解决办法:
./configure \
--prefix={$libxslt_prefix} \
--enable-static=yes \
--enable-shared=no \
--with-libxml-libs-prefix={$libxml2_prefix} \
--without-python \
--without-crypto \
--without-profiler \
--without-plugins \
--without-debugger
解决以后,链接参数就可以不需要
-framework CoreFoundation -framework SystemConfiguration
起因:
编译icu库时需要链接 c++ 标准库
macOS clang 不支持 libstdc++
经过验证结论: 链接c++ 库 :macOS 下使用libc++; linux 下使用libstdc++
$link_cpp = $p->getOsType() == 'macos' ? '-lc++' : '-lstdc++';
function install_pgsql(Preprocessor $p)
{
$p->addLibrary(
(new Library('pgsql'))
->withHomePage('https://www.postgresql.org/')
->withLicense('https://www.postgresql.org/about/licence/', Library::LICENSE_SPEC)
->withUrl('https://ftp.postgresql.org/pub/source/v15.1/postgresql-15.1.tar.gz')
//https://www.postgresql.org/docs/devel/installation.html
//https://www.postgresql.org/docs/devel/install-make.html#INSTALL-PROCEDURE-MAKE
->withManual('https://www.postgresql.org/docs/')
->withCleanBuildDirectory()
->withScriptBeforeConfigure(
'
test -d /usr/pgsql && rm -rf /usr/pgsql
'
)
->withConfigure(
'
./configure --help
sed -i.backup "s/invokes exit\'; exit 1;/invokes exit\';/" src/interfaces/libpq/Makefile
# 替换指定行内容
sed -i.backup "102c all: all-lib" src/interfaces/libpq/Makefile
# export CPPFLAGS="-static -fPIE -fPIC -O2 -Wall "
# export CFLAGS="-static -fPIE -fPIC -O2 -Wall "
export CPPFLAGS=$(pkg-config --cflags --static icu-uc icu-io icu-i18n readline libxml-2.0)
export LIBS=$(pkg-config --libs --static icu-uc icu-io icu-i18n readline libxml-2.0)
./configure --prefix=/usr/pgsql \
--enable-coverage=no \
--with-ssl=openssl \
--with-readline \
--with-icu \
--without-ldap \
--with-libxml \
--with-libxslt \
--with-includes="/usr/openssl/include/:/usr/libxml2/include/:/usr/libxslt/include:/usr/readline/include/readline:/usr/icu/include:/usr/zlib/include:/usr/include" \
--with-libraries="/usr/openssl/lib:/usr/libxml2/lib/:/usr/libxslt/lib/:/usr/readline/lib:/usr/icu/lib:/usr/zlib/lib:/usr/lib"
make -C src/include install
result_code=$?
[[ $result_code -ne 0 ]] && echo "[make FAILURE]" && exit $result_code;
make -C src/bin/pg_config install
result_code=$?
[[ $result_code -ne 0 ]] && echo "[make FAILURE]" && exit $result_code;
make -C src/common -j $cpu_nums all
make -C src/common install
result_code=$?
[[ $result_code -ne 0 ]] && echo "[make FAILURE]" && exit $result_code;
make -C src/port -j $cpu_nums all
make -C src/port install
result_code=$?
[[ $result_code -ne 0 ]] && echo "[make FAILURE]" && exit $result_code;
make -C src/backend/libpq -j $cpu_nums all
make -C src/backend/libpq install
result_code=$?
[[ $result_code -ne 0 ]] && echo "[make FAILURE]" && exit $result_code;
make -C src/interfaces/ecpg -j $cpu_nums all-pgtypeslib-recurse all-ecpglib-recurse all-compatlib-recurse all-preproc-recurse
make -C src/interfaces/ecpg install-pgtypeslib-recurse install-ecpglib-recurse install-compatlib-recurse install-preproc-recurse
result_code=$?
[[ $result_code -ne 0 ]] && echo "[make FAILURE]" && exit $result_code;
# 静态编译 src/interfaces/libpq/Makefile 有静态配置 参考: all-static-lib
make -C src/interfaces/libpq -j $cpu_nums # soname=true
make -C src/interfaces/libpq install
result_code=$?
[[ $result_code -ne 0 ]] && echo "[make FAILURE]" && exit $result_code;
rm -rf /usr/pgsql/lib/*.so.*
rm -rf /usr/pgsql/lib/*.so
return 0
'
)
->withPkgName('libpq')
->withPkgConfig('/usr/pgsql/lib/pkgconfig')
->withLdflags('-L/usr/pgsql/lib/')
->withBinPath('/usr/pgsql/bin/')
);
}
静态编译libffi
function install_libffi($p)
{
$p->addLibrary(
(new Library('libffi'))
->withHomePage('https://sourceware.org/libffi/')
->withLicense('http://github.com/libffi/libffi/blob/master/LICENSE', Library::LICENSE_BSD)
->withUrl('https://github.com/libffi/libffi/releases/download/v3.4.4/libffi-3.4.4.tar.gz')
->withFile('libffi-3.4.4.tar.gz')
->withPrefix('/usr/libffi/')
->withScriptBeforeConfigure(
'test -d /usr/libffi && rm -rf /usr/libffi'
)
->withConfigure(
'
./configure --help ;
./configure \
--prefix=/usr/libffi \
--enable-shared=no \
--enable-static=yes
'
)
->withPkgName('libffi')
->withPkgConfig('/usr/libffi/lib/pkgconfig')
->withLdflags('-L/usr/libffi/lib/')
->withBinPath('/usr/libffi/bin/')
//->withSkipInstall()
//->disablePkgName()
//->disableDefaultPkgConfig()
//->disableDefaultLdflags()
);
}
由于 wget 仅支持 http 代理,不支持 socks5 代理,导致无法使用代理。需要替换为 curl,curl 同时支持两种代理方式。
export http_proxy=socks5h://127.0.0.1:1080
export https_proxy=socks5h://127.0.0.1:1080
如题,待解决
考虑借鉴 phpbrew ,创建一个 $HOME/.swoole-cli/
目录,存储下载、构建以及目标文件
$HOME/.swoole-cli/source
:源代码包,替换当前的 pool/lib
和 pool/ext
$HOME/.swoole-cli/build
:构建时文件,替换当前的 thirdparty
目录$HOME/.swoole-cli/library
:在 macOS
系统下替换 /usr
目录if ($p->getOsType() == 'macos') {
$p->addEndCallback(function () use ($p) {
$header=<<<'EOF'
export PATH=/opt/homebrew/bin/:/usr/local/bin/:$PATH
EOF;
$command= file_get_contents(__DIR__ . '/make.sh');
$command=$header.PHP_EOL.$command;
file_put_contents(__DIR__ . '/make.sh',$command);
});
}
$p->addEndCallback(function () use ($p) {
$header=<<<'EOF'
#!/bin/env sh
set -uex
PKG_CONFIG_PATH='/usr/lib/pkgconfig'
test -d /usr/lib64/pkgconfig && PKG_CONFIG_PATH="/usr/lib64/pkgconfig:$PKG_CONFIG_PATH" ;
test -d /usr/local/lib64/pkgconfig && PKG_CONFIG_PATH="/usr/local/lib64/pkgconfig:$PKG_CONFIG_PATH" ;
cpu_nums=`nproc 2> /dev/null || sysctl -n hw.ncpu`
# `grep "processor" /proc/cpuinfo | sort -u | wc -l`
EOF;
$command= file_get_contents(__DIR__ . '/make.sh');
$command=$header.PHP_EOL.$command;
file_put_contents(__DIR__ . '/make.sh',$command);
});
使用 Github Action
自动构建,并上传发布:
Github swoole-src releases
Gitee swoole-src releases
Github swoole-clireleases
Gitee swoole-cli releases
OSS
(swoole.com/download
页面)咨询一下,我要编译arm环境,也是参考linux构建吗
需要自己build镜像是吧
按照make.sh中的指令进行安装完成
cd /work/thirdparty
echo "build cares"
mkdir -p /work/thirdparty/cares && \
tar --strip-components=1 -C /work/thirdparty/cares -xf /work/pool/lib/c-ares-1.18.1.tar.gz && \
cd cares && \
echo "./configure --prefix=/usr --enable-static --disable-shared"
./configure --prefix=/usr --enable-static --disable-shared && \
make -j 8 && \
make install
cd -
安装完成
list.3 ares_strerror.3 ares_timeout.3 ares_version.3 '/usr/share/man/man3'
make[2]: Leaving directory '/work/c-ares-1.18.1/docs'
make[1]: Leaving directory '/work/c-ares-1.18.1/docs'
Making install in test
make[1]: Entering directory '/work/c-ares-1.18.1/test'
make[2]: Entering directory '/work/c-ares-1.18.1/test'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/work/c-ares-1.18.1/test'
make[1]: Leaving directory '/work/c-ares-1.18.1/test'
make[1]: Entering directory '/work/c-ares-1.18.1'
make[2]: Entering directory '/work/c-ares-1.18.1'
make[2]: Nothing to be done for 'install-exec-am'.
./install-sh -c -d '/usr/lib/pkgconfig'
/usr/bin/install -c -m 644 libcares.pc '/usr/lib/pkgconfig'
make[2]: Leaving directory '/work/c-ares-1.18.1'
make[1]: Leaving directory '/work/c-ares-1.18.1'
执行make.sh build报以下异常
/work/swoole-cli/ext/swoole/ext-src/php_swoole_private.h:85:2: error: "Enable c-ares support, require c-ares library"
#error "Enable c-ares support, require c-ares library"
^
In file included from /work/swoole-cli/ext/swoole/ext-src/php_swoole_cxx.cc:1:
In file included from /work/swoole-cli/ext/swoole/ext-src/php_swoole_cxx.h:19:
/work/swoole-cli/ext/swoole/ext-src/php_swoole_private.h:85:2: error: "Enable c-ares support, require c-ares library"
#error "Enable c-ares support, require c-ares library"
^
/work/swoole-cli/ext/swoole/ext-src/php_swoole.cc:55:10: fatal error: 'ares.h' file not found
#include <ares.h>
^~~~~~~~
In file included from /work/swoole-cli/ext/swoole/ext-src/swoole_admin_server.cc:17:
In file included from /work/swoole-cli/ext/swoole/ext-src/php_swoole_server.h:21:
In file included from /work/swoole-cli/ext/swoole/ext-src/php_swoole_cxx.h:19:
/work/swoole-cli/ext/swoole/ext-src/php_swoole_private.h:85:2: error: "Enable c-ares support, require c-ares library"
#error "Enable c-ares support, require c-ares library"
^
2 errors generated.
make: *** [Makefile:1898: ext/swoole/ext-src/php_swoole.lo] Error 1
make: *** Waiting for unfinished jobs....
In file included from /work/swoole-cli/ext/swoole/ext-src/swoole_async_coro.cc:17:
In file included from /work/swoole-cli/ext/swoole/ext-src/php_swoole_cxx.h:19:
/work/swoole-cli/ext/swoole/ext-src/php_swoole_private.h:85:2: error: "Enable c-ares support, require c-ares library"
#error "Enable c-ares support, require c-ares library"
^
In file included from /work/swoole-cli/ext/swoole/ext-src/swoole_atomic.cc:17:
/work/swoole-cli/ext/swoole/ext-src/php_swoole_private.h:85:2: error: "Enable c-ares support, require c-ares library"
#error "Enable c-ares support, require c-ares library"
^
In file included from /work/swoole-cli/ext/swoole/ext-src/swoole_channel_coro.cc:20:
In file included from /work/swoole-cli/ext/swoole/ext-src/php_swoole_cxx.h:19:
/work/swoole-cli/ext/swoole/ext-src/php_swoole_private.h:85:2: error: "Enable c-ares support, require c-ares library"
#error "Enable c-ares support, require c-ares library"
^
1 error generated.
make: *** [Makefile:1910: ext/swoole/ext-src/swoole_atomic.lo] Error 1
1 error generated.
make: *** [Makefile:1901: ext/swoole/ext-src/php_swoole_cxx.lo] Error 1
In file included from /work/swoole-cli/ext/swoole/ext-src/swoole_client_coro.cc:17:
In file included from /work/swoole-cli/ext/swoole/ext-src/php_swoole_cxx.h:19:
/work/swoole-cli/ext/swoole/ext-src/php_swoole_private.h:85:2: error: "Enable c-ares support, require c-ares library"
#error "Enable c-ares support, require c-ares library"
^
In file included from /work/swoole-cli/ext/swoole/ext-src/swoole_client.cc:17:
In file included from /work/swoole-cli/ext/swoole/ext-src/php_swoole_cxx.h:19:
/work/swoole-cli/ext/swoole/ext-src/php_swoole_private.h:85:2: error: "Enable c-ares support, require c-ares library"
#error "Enable c-ares support, require c-ares library"
看了他的源码
执行的是:Swoole\Coroutine\Http\Server->__construct('0.0.0.0', 1765, false, true)
似乎是开启协程http服务器失败,这个有什么办法在win10启动吗
@jingjingxyk 请问为什么xlswriter被删除了?您一般使用什么方案来解决xls读写文件的?我们之前使用 PHPExcel ,但是速度慢,所以就换了。您下线掉 xlswriter 是因为有更好的选择吗?
未定义常量 GLOB_BRACE 的使用 in docker Alpine Linux
通过查阅文档和反复实践,确认了原因和解决办法
原因所在:
'mv ' . BROTLI_PREFIX . '/lib/libbrotlicommon-static.a ' . BROTLI_PREFIX . '/lib/libbrotli.a',
解决办法:
'cp ' . BROTLI_PREFIX . '/lib/libbrotlicommon-static.a ' . BROTLI_PREFIX . '/lib/libbrotli.a',
'mv ' . BROTLI_PREFIX . '/lib/libbrotlicommon-static.a ' . BROTLI_PREFIX . '/lib/libbrotlicommon.a',
最终解决:#36
新接触的人很难理解两边的差异,徒增成本。
自己新增内置扩展,同时又不修改本仓库源代码
install_php_internal_extensions
function ($p)
{
$workDir = $p->getWorkDir();
$p->addLibrary(
(new Library('php_internal_extensions'))
->withHomePage('https://www.php.net/')
->withLicense('https://github.com/php/php-src/blob/master/LICENSE', Library::LICENSE_PHP)
->withUrl('https://github.com/php/php-src/archive/refs/tags/php-8.1.12.tar.gz')
->withFile('php-8.1.12.tar.gz')
->withManual('https://www.php.net/docs.php')
->withLabel('php_internal_extension')
->withCleanBuildDirectory()
->withScriptBeforeConfigure(
"
test -d {$workDir}/ext/ffi && rm -rf {$workDir}/ext/ffi
cp -rf ext/ffi {$workDir}/ext/
test -d {$workDir}/ext/pdo_pgsql && rm -rf {$workDir}/ext/pdo_pgsql
cp -rf ext/pdo_pgsql {$workDir}/ext/
test -d {$workDir}/ext/pgsql && rm -rf {$workDir}/ext/pgsql
cp -rf ext/pgsql {$workDir}/ext/
"
)
->withConfigure('return 0')
->disablePkgName()
->disableDefaultPkgConfig()
->disableDefaultLdflags()
->withSkipBuildLicense()
);
}
macOS 下会指向 ~/.swoole_cli/openssl/ssl
,linux 会指向 /usr/openssl/ssl
用户需要创建软连接,可在编译 openssl 时指定证书路径,直接使用操作系统的证书
起因:
macOS 上启用opcache ,发现启用JIT 时,编译通过不了。进一步查看,发现会自动依赖库 capstone 、dynasm 等
#if defined(HAVE_DISASM) || defined(HAVE_GDB) || defined(HAVE_OPROFILE) || defined(HAVE_PERFTOOLS) || defined(HAVE_VTUNE)
另外一种解决办法是 卸载本机的 capstone dynasm 库
希望能添加一个xlswriter扩展 excel扩展 谢谢峰哥!
web ui (雏形 暂只启用前端页面页面) : https://swoole-cli-ui.jingjingxyk.com/
视频: https://www.bilibili.com/video/BV1Eb4y1n7xE/
视频节点: 0:58:34
视频节点: 1:02:44
视频节点: 1:05:34
swoole-cli 实验分支 experiment
借助 swoole-cli 项目提供的依赖库,编译器PHP其他版本 ,使用这个分支 build_native_php
其他:
借助依赖库 micro 二进制版本 build_native_php_sfx_micro
php-7.3.33
php-7.4.33
完整步骤:
bash sapi/quickstart/setup-php-runtime.sh --mirror china
bash sapi/quickstart/linux/run-alpine-3.16-container-full.sh
# 进入容器
bash sapi/quickstart/linux/connection-swoole-cli-alpine.sh
sh sapi/quickstart/linux/alpine-3.16-init.sh --mirror china
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
composer update --no-dev --optimize-autoloader
php prepare.php --with-global-prefix=/usr --with-download-mirror-url=https://swoole-cli.jingjingxyk.com/ +protobuf
# bash make.sh all-library (这步省略,因为已经通过容器技术提前构建好依赖库,并打包到容器中,运行容器已经包含依赖库)
bash make.sh config
bash make.sh build
bash make.sh archive
1、搭配 quickstart 脚本
2、使用高配置云服务抢占式实例 快速构建 ;成果看这里: jingjingxyk#52
如何新增php的ssh2扩展
clang: warning: argument unused during compilation: '-fno-ident' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-all-static' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-fno-ident' [-Wunused-command-line-argument]
这些参数是无效的
文档 doc-macos.md
## curl configure 检测不通过
修改 `ext/curl/config.m4` ,去掉 `HAVE_CURL` 检测
依据上述文档的提示:写如下功能
function install_php_internal_extension_curl_patch(Preprocessor $p)
{
$workDir=$p->getWorkDir();
$command = '';
if(is_file("{$workDir}/ext/curl/config.m4.backup")){
$originFileHash=md5(file_get_contents("{$workDir}/ext/curl/config.m4"));
$backupFileHash=md5(file_get_contents("{$workDir}/ext/curl/config.m4.backup"));
if($originFileHash == $backupFileHash){
$command =<<<EOF
test -f {$workDir}/ext/curl/config.m4.backup && rm -f {$workDir}/ext/curl/config.m4.backup
test -f {$workDir}/ext/curl/config.m4.backup || sed -i.backup '75,82d' {$workDir}/ext/curl/config.m4
EOF;
}
} else {
$command =<<<EOF
test -f {$workDir}/ext/curl/config.m4.backup || sed -i.backup '75,82d' {$workDir}/ext/curl/config.m4
EOF;
}
$p->addLibrary(
(new Library('patch_php_internal_extension_curl'))
->withHomePage('https://www.php.net/')
->withLicense('https://github.com/php/php-src/blob/master/LICENSE', Library::LICENSE_PHP)
->withUrl('https://github.com/php/php-src/archive/refs/tags/php-8.1.12.tar.gz')
->withManual('https://www.php.net/docs.php')
->withLabel('php_extension_patch')
->withScriptBeforeConfigure($command)
->withConfigure('return 0 ')
->disableDefaultPkgConfig()
->disableDefaultLdflags()
->disablePkgName()
);
}
缘由: 反复尝试 github action windows-latest 环境,发现编译始终不通过
解决办法: 用一台全新的服务器来编译测试 ,找到问题所在。
阿里云按量付费服务器 4核16G windows 2022 数据中心版 服务器成本:3元RMB左右
安装 cygwin setup-x86_64.exe依赖,花费半小时左右 (有情提醒: 提前准备好安装包等,可以节省时间)
提前准备脚本如下: (备注 ^ 是windows cmd 换行符)
setup-x86_64.exe --no-desktop --no-shortcuts --no-startmenu --quiet-mode -s https://mirrors.ustc.edu.cn/cygwin/ -P git,curl,wget,tar,libtool,re2c,bison,gcc-g++,autoconf,automake,openssl,libpcre2-devel,libssl-devel,libcurl-devel,libxml2-devel,libxslt-devel,libgmp-devel,ImageMagick,libpng-devel,libjpeg-devel,libfreetype-devel,libwebp-devel,libsqlite3-devel,zlib-devel,libbz2-devel,liblz4-devel,liblzma-devel,libzip-devel,libicu-devel,libonig-devel,libcares-devel,libsodium-devel,libyaml-devel,libMagick-devel,libzstd-devel,libbrotli-devel,libreadline-devel,libintl-devel,libpq-devel,libssh2-devel,libidn2-devel,gettext-devel,coreutils
发现问题所在: 因github runner 已经内置了msys
环境, cygwin
如果不安装 make
,默认引用的是 mingw-make
。需要cygwin
安装 make
解决问题 。另外还有需要创建目录 mkdir -p bin/.libs
配置系统变量PATH 以后,是可以使用的
# 设置软连接
mklink "C:\Users\biubiu\Downloads\swoole-cli-v5.0.1-cygwin64\bin\php.exe" "C:\Users\biubiu\Downloads\swoole-cli-v5.0.1-cygwin64\bin\swoole-cli.exe"
swoole-cli -v
php -v
get_dir.php
<?php
echo __DIR__;
php get_dir.php
但是当使用魔术变量 __DIR__
时,返回的路径不存在
操作系统是不是还必须安装 cygwin
?
安装cygwin
setup-x86_64.exe -B -O -s http://cygwin.mirror.constant.com
cygwin 是否有版本要求?
比如:php 7.4 、 php 8.20
第一步:运行已经构建好依赖库的容器:
这两个容器镜像都是一样的,区别是:容器镜像的生成过程不同
前者通过docker commit
生成
后者通过Dockerfile
分步构建生成
#!/bin/env sh
__DIR__=$(
cd "$(dirname "$0")"
pwd
)
image=phpswoole/swoole-cli-builder:1.6
image=registry.cn-beijing.aliyuncs.com/jingjingxyk-public/app:build-swoole-cli-build-dependencies-alpine-edge-20230226T074232Z
docker run --rm --name swoole-cli-build-dev-all-dependencies-container -d -v ${__DIR__}:/work -w /work $image tail -f /dev/null
第二步:静态编译PHP
这三个分支,选择自己需要的,他们之间变化并不大哈。自己修改PHP 版本就行
build_native_php
build_php_8.2
build_php_7.4
build_php_7.3 需要更换为GCC 、glibc
步骤也没变
php prepare.php
sh make.sh all_library
sh make.sh php_src # 这一步执行下载PHP 源码,并把需要的扩展的源码拷贝到 PHP源码目录
sh amke.sh config
sh make.sh build
sh make.sh archive
一直在关注cli的更新情况,希望可以支持把hyperf
框架打包的phar
包直接编译进cli,这样分发出去只要给一个文件就够了
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.