diff --git a/tests/test.bats b/tests/test.bats index 024f695..13f1b21 100644 --- a/tests/test.bats +++ b/tests/test.bats @@ -52,6 +52,8 @@ health_checks() { assert_output --partial "PHP ${FRANKENPHP_PHP_VERSION}" refute_output --partial "Warning" refute_output --partial "is already loaded" + refute_output --partial "cannot open shared object file" + refute_output --partial "in Unknown on line" run ddev php --ini assert_success @@ -164,31 +166,28 @@ health_checks() { assert_line "zip" if [[ "${FRANKENPHP_CUSTOM_EXTENSION}" == "true" ]]; then - assert_output --partial "example_pie_extension" + assert_line "example_pie_extension" else - refute_output --partial "example_pie_extension" + refute_line "example_pie_extension" fi - run ddev xdebug on - assert_success - - run ddev php -m - assert_success - assert_output --partial "xdebug" - - run ddev xhprof on - assert_success - - run ddev php -m - assert_success - assert_output --partial "xhprof" + refute_output --partial "Warning" + refute_output --partial "is already loaded" + refute_output --partial "cannot open shared object file" + refute_output --partial "in Unknown on line" - run ddev blackfire on - assert_success + for extension in xdebug xhprof blackfire; do + run ddev "${extension}" on + assert_success - run ddev php -m - assert_success - assert_output --partial "blackfire" + run ddev php -m + assert_success + assert_line "${extension}" + refute_output --partial "Warning" + refute_output --partial "is already loaded" + refute_output --partial "cannot open shared object file" + refute_output --partial "in Unknown on line" + done } teardown() { diff --git a/web-build/Dockerfile.frankenphp b/web-build/Dockerfile.frankenphp index 5796611..eed5faf 100644 --- a/web-build/Dockerfile.frankenphp +++ b/web-build/Dockerfile.frankenphp @@ -17,8 +17,26 @@ sed -i 's|/etc/php/${DDEV_PHP_VERSION}/fpm/conf.d/|/etc/php-zts/conf.d/|g' /star # Copy DDEV PHP module configurations to php-zts location cp /etc/php/${DDEV_PHP_VERSION}/mods-available/assert.ini /etc/php-zts/conf.d/20-assert.ini cp /etc/php/${DDEV_PHP_VERSION}/mods-available/blackfire.ini /etc/php-zts/conf.d/90-blackfire.ini -cp /etc/php/${DDEV_PHP_VERSION}/mods-available/xdebug.ini /etc/php-zts/conf.d/15-xdebug.ini -cp /etc/php/${DDEV_PHP_VERSION}/mods-available/xhprof.ini /etc/php-zts/conf.d/20-xhprof.ini + +# Append DDEV extension configurations to existing php-zts ini files +for EXT_NAME in xdebug xhprof; do + # Find the source extension ini file in mods-available + EXT_SRC_INI=$(find "/etc/php/${DDEV_PHP_VERSION}/mods-available" -name "*${EXT_NAME}*.ini" -type f | head -n 1) + if [ -z "$EXT_SRC_INI" ]; then + echo "ERROR: ${EXT_NAME} ini file not found in /etc/php/${DDEV_PHP_VERSION}/mods-available" >&2 + exit 1 + fi + + # Find the destination extension ini file in php-zts conf.d + EXT_ZTS_INI=$(find /etc/php-zts/conf.d -name "*${EXT_NAME}*.ini" -type f | head -n 1) + if [ -z "$EXT_ZTS_INI" ]; then + echo "ERROR: ${EXT_NAME} ini file not found in /etc/php-zts/conf.d" >&2 + exit 1 + fi + + # Append config from mods-available, excluding extension loading lines + grep -v -E '^(zend_)?extension=' "$EXT_SRC_INI" >> "$EXT_ZTS_INI" +done # Create symlinks for phpenmod and phpdismod to use php-zts versions ln -sf /usr/sbin/phpenmod-zts /usr/sbin/phpenmod @@ -26,6 +44,8 @@ ln -sf /usr/sbin/phpdismod-zts /usr/sbin/phpdismod # Reconfigure blackfire-php if installed, to match the current PHP version if dpkg -s blackfire-php >/dev/null 2>&1; then + apt-get update || true + apt-get install -y --only-upgrade blackfire-php dpkg-reconfigure blackfire-php fi