- Removed custom setup-php-apt action that installed PHP from Ondrej PPA - Switched to using shivammathur/setup-php@v2 community action - Updated workflow jobs to use ubuntu-latest instead of ubuntu-24.04 - Configured PHP extensions (curl, redis, mbstring, ffi) via setup action - Set PHP ini values through action configuration including FFI enable, memory limits, and error reporting settings - Updated PHP embed library installationdebug/ci-class-id-cache
parent
821f639e8f
commit
7f587749f1
2 changed files with 54 additions and 110 deletions
@ -1,97 +0,0 @@ |
||||
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 |
||||
php_packages=( \ |
||||
"php${PHP_VERSION}-cli" \ |
||||
"php${PHP_VERSION}-common" \ |
||||
"php${PHP_VERSION}-curl" \ |
||||
"php${PHP_VERSION}-dev" \ |
||||
"php${PHP_VERSION}-mbstring" \ |
||||
"php${PHP_VERSION}-readline" \ |
||||
"php${PHP_VERSION}-redis" \ |
||||
"php${PHP_VERSION}-xml" \ |
||||
"php${PHP_VERSION}-zip" \ |
||||
"libphp${PHP_VERSION}-embed" \ |
||||
) |
||||
if apt-cache show "php${PHP_VERSION}-opcache" >/dev/null 2>&1; then |
||||
php_packages+=("php${PHP_VERSION}-opcache") |
||||
fi |
||||
sudo apt-get install --yes "${php_packages[@]}" |
||||
|
||||
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 |
||||
if test -f "/etc/php/${PHP_VERSION}/mods-available/opcache.ini"; then |
||||
sudo phpenmod -v "${PHP_VERSION}" opcache |
||||
else |
||||
echo "OPcache is not available in the PPA for PHP ${PHP_VERSION}" |
||||
fi |
||||
|
||||
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"] as $extension) { if (!extension_loaded($extension)) { fwrite(STDERR, "Missing PHP extension: $extension\n"); exit(1); } }' |
||||
if test -f "/etc/php/${PHP_VERSION}/mods-available/opcache.ini"; then |
||||
php -r 'if (!extension_loaded("Zend OPcache")) { fwrite(STDERR, "Missing PHP extension: Zend OPcache\n"); exit(1); }' |
||||
fi |
||||
composer --version |
||||
echo "Using ${embed_library} from ${embed_package} ${embed_version}" |
||||
Loading…
Reference in new issue