Skip to content

Commit

Permalink
Merge pull request #11 from kevin-studer/php_xdebug
Browse files Browse the repository at this point in the history
Automatic configuration of xdebug
  • Loading branch information
shyim authored May 2, 2024
2 parents 979b6a7 + e22bf7a commit 7f62a1e
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 2 deletions.
18 changes: 17 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,22 @@ jobs:
- name: "Generating tests for '${{ matrix.features }}' against '${{ matrix.baseImage }}'"
run: devcontainer features test -f ${{ matrix.features }} -i ${{ matrix.baseImage }} .

test-scenarios:
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
features:
- php
steps:
- uses: actions/checkout@v3

- name: "Install latest devcontainer CLI"
run: npm install -g @devcontainers/cli

- name: "Testing '${{ matrix.features }}' scenarios"
run: devcontainer features test -f ${{ matrix.features }} --skip-autogenerated .

test-global:
runs-on: ubuntu-latest
continue-on-error: true
Expand All @@ -43,4 +59,4 @@ jobs:
run: npm install -g @devcontainers/cli

- name: "Testing global scenarios"
run: devcontainer features test --global-scenarios-only .
run: devcontainer features test --global-scenarios-only .
15 changes: 14 additions & 1 deletion src/php/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ if [[ "$OS" == '"Ubuntu"' ]]; then
if [[ "$VERSION_CODENAME" == "focal" ]]; then
echo "Detected: Ubuntu Focal (20.04)"
echo "deb https://ppa.launchpadcontent.net/ondrej/php/ubuntu focal main" > /etc/apt/sources.list.d/ondrej-php.list
else
elif [[ "$VERSION_CODENAME" == "jammy" ]]; then
echo "Detected: Ubuntu Jammy (22.04)"
echo "deb https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ondrej-php.list
else
echo "Detected: Ubuntu Noble (24.04)"
echo "deb https://ppa.launchpadcontent.net/ondrej/php/ubuntu noble main" > /etc/apt/sources.list.d/ondrej-php.list
fi

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C
Expand Down Expand Up @@ -67,3 +70,13 @@ if [[ $INSTALLCOMPOSER == "true" ]]; then
php composer-setup.php --install-dir=/usr/local/bin --filename=composer
rm composer-setup.php
fi

if [[ "${MODULES[@]}" =~ "xdebug" ]]; then
XDEBUG_INI="/etc/php/${VERSION}/mods-available/xdebug.ini"

echo "" >> "${XDEBUG_INI}"
echo "xdebug.mode = debug" >> "${XDEBUG_INI}"
echo "xdebug.start_with_request = yes" >> "${XDEBUG_INI}"
echo "xdebug.client_port = 9003" >> "${XDEBUG_INI}"
fi

13 changes: 13 additions & 0 deletions test/php/install_php_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -e

# Optional: Import test library
source dev-container-features-test-lib

check "php-version-8-is-installed" bash -c "php --version | grep '8.0'"
check "php-fpm-version-8-is-installed" bash -c "php-fpm8.0 --version | grep '8.0'"
check "composer-version" composer --version

# Report result
reportResults
18 changes: 18 additions & 0 deletions test/php/install_php_xdebug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -e

# Optional: Import test library bundled with the devcontainer CLI
source dev-container-features-test-lib

# Feature-specific tests
# The 'check' command comes from the dev-container-features-test-lib.
check "php -v" php -v
check "php-fpm -v" php-fpm8.2 -v

check "php-xdebug-extension" php -m | grep "xdebug"
check "php-xdebug-config" php -i | grep "xdebug.mode" | grep " => debug"

# Report result
# If any of the checks above exited with a non-zero exit code, the test will fail.
reportResults
18 changes: 18 additions & 0 deletions test/php/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"install_php_version": {
"image": "ubuntu:latest",
"features": {
"php": {
"version": "8.0"
}
}
},
"install_php_xdebug": {
"image": "ubuntu:latest",
"features": {
"php": {
"extensionsExtra": "xdebug"
}
}
}
}

0 comments on commit 7f62a1e

Please sign in to comment.