Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shell 脚本中启用 别名扩展功能 #915

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 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__=$(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

```

* 脚本会自动下载相关的`C/C++`库以及`PECL`扩展
Expand Down
5 changes: 4 additions & 1 deletion 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 Expand Up @@ -190,7 +193,7 @@ if [ ${IN_DOCKER} -eq 1 ]; then
{
# 容器中

php prepare.php +inotify ${OPTIONS}
php prepare.php ${OPTIONS}

}
else
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
Loading