- Replace shivammathur/setup-php@v2 with custom setup-php-apt action - Update all workflow jobs to use ubuntu-24.04 runner - Create new composite action for installing PHP from Ondrej PPA - Simplify PHP configuration by using predefined ini settings - Remove redundant apt-get update commands in build steps - Update PHP embed library configuration and linking - Fix ldd command regex pattern for libphp.so detection - Standardize PHP INI directory paths across all workflows - Remove unused PHP_INI_SCAN_DIR environment variable exportsmaster
parent
e4817819dc
commit
978e553480
2 changed files with 99 additions and 55 deletions
@ -0,0 +1,85 @@ |
||||
name: Setup PHP from Ondrej PPA |
||||
description: Install a version-matched PHP CLI, development SDK, extensions and Embed SAPI. |
||||
|
||||
inputs: |
||||
php-version: |
||||
description: PHP major.minor version to install. |
||||
required: true |
||||
|
||||
runs: |
||||
using: composite |
||||
steps: |
||||
- name: Install PHP and extensions |
||||
shell: bash |
||||
env: |
||||
PHP_VERSION: ${{ inputs.php-version }} |
||||
run: | |
||||
set -euo pipefail |
||||
export DEBIAN_FRONTEND=noninteractive |
||||
|
||||
sudo apt-get update |
||||
sudo apt-get install --yes software-properties-common |
||||
sudo add-apt-repository --yes ppa:ondrej/php |
||||
sudo apt-get update |
||||
sudo apt-get install --yes \ |
||||
"php${PHP_VERSION}-cli" \ |
||||
"php${PHP_VERSION}-common" \ |
||||
"php${PHP_VERSION}-curl" \ |
||||
"php${PHP_VERSION}-dev" \ |
||||
"php${PHP_VERSION}-mbstring" \ |
||||
"php${PHP_VERSION}-opcache" \ |
||||
"php${PHP_VERSION}-readline" \ |
||||
"php${PHP_VERSION}-redis" \ |
||||
"php${PHP_VERSION}-xml" \ |
||||
"php${PHP_VERSION}-zip" \ |
||||
"libphp${PHP_VERSION}-embed" |
||||
|
||||
sudo update-alternatives --set php "/usr/bin/php${PHP_VERSION}" |
||||
sudo update-alternatives --set phpize "/usr/bin/phpize${PHP_VERSION}" |
||||
sudo update-alternatives --set php-config "/usr/bin/php-config${PHP_VERSION}" |
||||
sudo phpenmod -v "${PHP_VERSION}" ffi opcache |
||||
|
||||
php_ini_dir="/etc/php/${PHP_VERSION}/cli/conf.d" |
||||
printf '%s\n' \ |
||||
'ffi.enable=1' \ |
||||
'phpy.enable_operator_overloading=0' \ |
||||
'opcache.jit=0' \ |
||||
'precision=17' \ |
||||
'memory_limit=4G' \ |
||||
'error_reporting=E_ERROR | E_WARNING' \ |
||||
'display_errors=1' \ |
||||
'display_startup_errors=1' \ |
||||
'log_errors=0' \ |
||||
| sudo tee "${php_ini_dir}/99-typephp-ci.ini" >/dev/null |
||||
|
||||
embed_package="libphp${PHP_VERSION}-embed" |
||||
php_version="$(php-config --version)" |
||||
embed_version="$(dpkg-query --show --showformat='${Version}' "${embed_package}")" |
||||
case "${embed_version}" in |
||||
"${php_version}"*) ;; |
||||
*) |
||||
echo "${embed_package} ${embed_version} does not match PHP ${php_version}" >&2 |
||||
exit 1 |
||||
;; |
||||
esac |
||||
|
||||
embed_library="$(dpkg-query --listfiles "${embed_package}" \ |
||||
| sed -n '/\/libphp[0-9][^/]*\.so$/ { p; q; }')" |
||||
test -n "${embed_library}" |
||||
test -f "${embed_library}" |
||||
|
||||
php_home="${RUNNER_TEMP}/typephp-php-${PHP_VERSION}" |
||||
mkdir -p "${php_home}/bin" "${php_home}/include" "${php_home}/lib" |
||||
ln -s "$(command -v php-config)" "${php_home}/bin/php-config" |
||||
ln -s "$(php-config --include-dir)" "${php_home}/include/php" |
||||
ln -s "${embed_library}" "${php_home}/lib/libphp.so" |
||||
ln -s "${embed_library}" "${php_home}/lib/$(basename "${embed_library}")" |
||||
|
||||
echo "PHP_HOME=${php_home}" >> "${GITHUB_ENV}" |
||||
echo "PHP_INI_SCAN_DIR=${php_ini_dir}" >> "${GITHUB_ENV}" |
||||
echo "PHP_EMBED_LIBRARY=${embed_library}" >> "${GITHUB_ENV}" |
||||
|
||||
test "$(php -r 'echo PHP_MAJOR_VERSION, ".", PHP_MINOR_VERSION;')" = "${PHP_VERSION}" |
||||
php -r 'foreach (["curl", "ffi", "mbstring", "redis", "xml", "zip", "Zend OPcache"] as $extension) { if (!extension_loaded($extension)) { fwrite(STDERR, "Missing PHP extension: $extension\n"); exit(1); } }' |
||||
composer --version |
||||
echo "Using ${embed_library} from ${embed_package} ${embed_version}" |
||||
Loading…
Reference in new issue