diff --git a/README.md b/README.md index 1989bead4d..8d0fd4dab1 100644 --- a/README.md +++ b/README.md @@ -84,14 +84,26 @@ bash setup-php-runtime.sh # 来自 https://www.swoole.com/download bash setup-php-runtime.sh --mirror china +# 使用swoole-cli +# shell脚本中启用别名扩展功能‌ +shopt -s expand_aliases +__DIR__=$(cd "$(dirname "$0")"; pwd) +export PATH="${__DIR__}/bin/runtime:$PATH" +ln -sf ${__DIR__}/bin/runtime/swoole-cli ${__DIR__}/bin/runtime/php +alias php="php -d curl.cainfo=${__DIR__}/bin/runtime/cacert.pem -d openssl.cafile=${__DIR__}/bin/runtime/cacert.pem" +which php +php -v + ``` ## 生成构建脚本 ```shell + composer install -php prepare.php -php prepare.php +inotify +mongodb -mysqli +prepare.php +prepare.php +inotify +mongodb -mysqli + ``` * 脚本会自动下载相关的`C/C++`库以及`PECL`扩展 diff --git a/build-release-example.sh b/build-release-example.sh index c42bd75e88..a621e67d24 100644 --- a/build-release-example.sh +++ b/build-release-example.sh @@ -146,6 +146,9 @@ if [ ! -f "${__PROJECT__}/bin/runtime/php" ]; then fi export PATH="${__PROJECT__}/bin/runtime:$PATH" +# 交互模式下alias 扩展默认是开启的,脚本模式下默认是关闭的 +# 在shell脚本中启用别名扩展功能‌ +shopt -s expand_aliases alias php="php -d curl.cainfo=${__PROJECT__}/bin/runtime/cacert.pem -d openssl.cafile=${__PROJECT__}/bin/runtime/cacert.pem" php -v diff --git a/sapi/src/template/make.php b/sapi/src/template/make.php index 3abcae7707..ae2ee94735 100755 --- a/sapi/src/template/make.php +++ b/sapi/src/template/make.php @@ -8,6 +8,7 @@ ?> #!/usr/bin/env bash +shopt -s expand_aliases __PROJECT_DIR__=$(cd "$(dirname "$0")"; pwd) CLI_BUILD_TYPE=getBuildType() . PHP_EOL ?> SRC=phpSrcDir . PHP_EOL ?> diff --git a/setup-php-runtime.sh b/setup-php-runtime.sh index 7707875f08..4dd9cb4b5a 100644 --- a/setup-php-runtime.sh +++ b/setup-php-runtime.sh @@ -154,10 +154,12 @@ cd ${__PROJECT__}/ set +x echo " " -echo " USE PHP RUNTIME :" +echo " USE PHP RUNTIME : " echo " " echo " export PATH=\"${__PROJECT__}/bin/runtime:\$PATH\" " echo " " +echo " shopt -s expand_aliases " +echo " " echo " alias php='php -d curl.cainfo=${__PROJECT__}/bin/runtime/cacert.pem -d openssl.cafile=${__PROJECT__}/bin/runtime/cacert.pem' " echo " OR " echo " alias php='php -c ${__PROJECT__}/bin/runtime/php.ini' " diff --git a/setup-swoole-cli-runtime.sh b/setup-swoole-cli-runtime.sh index d4785cf1b6..c9b4ea66ac 100644 --- a/setup-swoole-cli-runtime.sh +++ b/setup-swoole-cli-runtime.sh @@ -228,6 +228,8 @@ echo " USE PHP-CLI RUNTIME :" echo " " echo " export PATH=\"${__PROJECT__}/bin/runtime:\$PATH\" " echo " " +echo " shopt -s expand_aliases " +echo " " echo " alias swoole-cli='swoole-cli -d curl.cainfo=${__PROJECT__}/bin/runtime/cacert.pem -d openssl.cafile=${__PROJECT__}/bin/runtime/cacert.pem' " echo " OR " echo " alias swoole-cli='swoole-cli -c ${__PROJECT__}/bin/runtime/php.ini' "