Skip to content

Commit

Permalink
feature: include php.ini from current dir when available
Browse files Browse the repository at this point in the history
Currently, the php.ini file of the current working directory
is not included.

This has been changed to include the php.ini file of the current
working directory by setting "sapi_module->php_ini_ignore_cwd = 0"
before buildconf.
  • Loading branch information
ochorocho committed Jan 19, 2024
1 parent 00b1d0e commit 3d5f405
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 5 additions & 3 deletions build-static.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

set -o errexit

ROOT_DIR="$(pwd)"

if ! type "git" > /dev/null; then
echo "The \"git\" command must be installed."
exit 1
Expand All @@ -18,7 +20,7 @@ if [ -z "${PHP_EXTENSIONS}" ]; then
# Temporary fix for https://github.com/crazywhalecc/static-php-cli/issues/280 (remove ldap)
export PHP_EXTENSIONS="apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,gd,iconv,igbinary,intl,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,readline,redis,session,simplexml,sockets,sodium,sqlite3,sysvsem,tokenizer,xml,xmlreader,xmlwriter,zip,zlib"
else
export PHP_EXTENSIONS="apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,gd,iconv,igbinary,intl,ldap,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,readline,redis,session,simplexml,sockets,sodium,sqlite3,sysvsem,tokenizer,xml,xmlreader,xmlwriter,zip,zlib"
export PHP_EXTENSIONS="apcu,bcmath,bz2,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,gd,iconv,igbinary,intl,ldap,mbregex,mbstring,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_pgsql,pdo_sqlite,pgsql,phar,posix,readline,redis,session,simplexml,sockets,sodium,sqlite3,sysvsem,tokenizer,xml,xmlreader,xmlwriter,zip,zlib"
fi
fi

Expand Down Expand Up @@ -59,7 +61,7 @@ fi

# Build libphp if ncessary
if [ -f "dist/static-php-cli/buildroot/lib/libphp.a" ]; then
cd dist/static-php-cli
cd dist/static-php-cli
else
mkdir -p dist/
cd dist/
Expand Down Expand Up @@ -98,7 +100,7 @@ else
./bin/spc doctor
./bin/spc fetch --with-php="${PHP_VERSION}" --for-extensions="${PHP_EXTENSIONS}"
# shellcheck disable=SC2086
./bin/spc build --enable-zts --build-embed ${extraOpts} "${PHP_EXTENSIONS}" --with-libs="${PHP_EXTENSION_LIBS}"
./bin/spc build --enable-zts --build-embed ${extraOpts} "${PHP_EXTENSIONS}" --with-libs="${PHP_EXTENSION_LIBS}" -P "${ROOT_DIR}/custom-ini.php"
fi

CGO_CFLAGS="-DFRANKENPHP_VERSION=${FRANKENPHP_VERSION} $(./buildroot/bin/php-config --includes | sed s#-I/#-I"${PWD}"/buildroot/#g)"
Expand Down
9 changes: 9 additions & 0 deletions custom-ini.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
// patch it before `./buildconf` executed
if (patch_point() === 'before-php-buildconf') {
\SPC\store\FileSystem::replaceFileStr(
SOURCE_PATH . '/php-src/sapi/cli/php_cli.c',
'sapi_module->php_ini_ignore_cwd = 1;',
'sapi_module->php_ini_ignore_cwd = 0;'
);
}

0 comments on commit 3d5f405

Please sign in to comment.