Skip to content

Commit

Permalink
shell 脚本中启用 别名扩展功能
Browse files Browse the repository at this point in the history
  • Loading branch information
jingjingxyk committed Jan 25, 2025
1 parent e655263 commit 068e9a9
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`扩展
Expand Down
3 changes: 3 additions & 0 deletions build-release-example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions sapi/src/template/make.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

?>
#!/usr/bin/env bash
shopt -s expand_aliases
__PROJECT_DIR__=$(cd "$(dirname "$0")"; pwd)
CLI_BUILD_TYPE=<?= $this->getBuildType() . PHP_EOL ?>
SRC=<?= $this->phpSrcDir . PHP_EOL ?>
Expand Down
4 changes: 3 additions & 1 deletion setup-php-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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' "
Expand Down
2 changes: 2 additions & 0 deletions setup-swoole-cli-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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' "
Expand Down

0 comments on commit 068e9a9

Please sign in to comment.