Skip to content

Commit

Permalink
Add pcov extension (#78)
Browse files Browse the repository at this point in the history
* Add pcov extension

* Add command

* Better

---------

Co-authored-by: Christian Fritsch <[email protected]>
  • Loading branch information
chrfritsch and Christian Fritsch authored Jul 25, 2024
1 parent 7f0b9c2 commit 2fd5a36
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .ddev/commands/web/pcov
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

## #ddev-generated
## Description: Enable or disable pcov
## Usage: pcov on|off|enable|disable|true|false|toggle|status
## Example: "ddev pcov" (default is "on"), "ddev pcov off", "ddev pcov on", "ddev pcov toggle", "ddev pcov status"
## ExecRaw: false
## Flags: []
## AutocompleteTerms: ["on","off","enable","disable","toggle","status"]

get_pcov_status() {
php -r 'echo extension_loaded("pcov") ? "1" : "0";'
}

enable_pcov() {
phpenmod -v "${DDEV_PHP_VERSION}" pcov
}

disable_pcov() {
phpdismod -v "${DDEV_PHP_VERSION}" pcov
}

if [ $# -eq 0 ] ; then
enable_pcov
exit
fi

case $1 in
on|true|enable)
enable_pcov
;;
off|false|disable)
disable_pcov
;;
toggle)
status=$(get_pcov_status)
if [ "${status}" = "1" ]; then
disable_pcov
else
enable_pcov
fi
;;
status)
status=$(get_pcov_status)
if [ "${status}" = "1" ]; then
result="pcov enabled"
else
result="pcov disabled"
fi
echo $result
;;
*)
echo "Invalid argument: $1"
;;
esac
7 changes: 7 additions & 0 deletions .ddev/web-build/Dockerfile.pcov
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ENV extension=pcov
SHELL ["/bin/bash", "-c"]
# Install the needed development packages
RUN (apt-get update || true) && DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::="--force-confnew" --no-install-recommends --no-install-suggests build-essential php-pear php${DDEV_PHP_VERSION}-dev
# Install the extension
RUN pecl install ${extension}
RUN echo "extension=${extension}.so" > /etc/php/${DDEV_PHP_VERSION}/mods-available/${extension}.ini && chmod 666 /etc/php/${DDEV_PHP_VERSION}/mods-available/${extension}.ini

0 comments on commit 2fd5a36

Please sign in to comment.