From b2de93cc1ba10c06c39f5ff6cc58756c484e5960 Mon Sep 17 00:00:00 2001 From: Alec Joy Date: Sun, 4 Aug 2019 14:07:05 -0400 Subject: [PATCH 1/5] Add support for pcov code coverage driver --- DOCUMENTATION/content/documentation/index.md | 23 ++++++++++++++++++++ docker-compose.yml | 2 ++ env-example | 2 ++ php-fpm/Dockerfile | 19 ++++++++++++++++ workspace/Dockerfile | 19 ++++++++++++++++ 5 files changed, 65 insertions(+) diff --git a/DOCUMENTATION/content/documentation/index.md b/DOCUMENTATION/content/documentation/index.md index a9aeb8a1..55fbb1fd 100644 --- a/DOCUMENTATION/content/documentation/index.md +++ b/DOCUMENTATION/content/documentation/index.md @@ -299,6 +299,29 @@ For information on how to configure xDebug with your IDE and work it out, check +
+ +## Install pcov + +1 - First install `pcov` in the Workspace and the PHP-FPM Containers: +
+a) open the `.env` file +
+b) search for the `WORKSPACE_INSTALL_PCOV` argument under the Workspace Container +
+c) set it to `true` +
+d) search for the `PHP_FPM_INSTALL_PCOV` argument under the PHP-FPM Container +
+e) set it to `true` + +2 - Re-build the containers `docker-compose build workspace php-fpm` + +Note that pcov is only supported on PHP 7.1 or newer. For more information on setting up pcov optimally, check the recommended section +of the [README](https://github.com/krakjoe/pcov) + + +
## Start/Stop xDebug: diff --git a/docker-compose.yml b/docker-compose.yml index e4a4fc4b..5374b8d2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -59,6 +59,7 @@ services: - LARADOCK_PHALCON_VERSION=${PHALCON_VERSION} - INSTALL_SUBVERSION=${WORKSPACE_INSTALL_SUBVERSION} - INSTALL_XDEBUG=${WORKSPACE_INSTALL_XDEBUG} + - INSTALL_PCOV=${WORKSPACE_INSTALL_PCOV} - INSTALL_PHPDBG=${WORKSPACE_INSTALL_PHPDBG} - INSTALL_BLACKFIRE=${INSTALL_BLACKFIRE} - INSTALL_SSH2=${WORKSPACE_INSTALL_SSH2} @@ -148,6 +149,7 @@ services: - LARADOCK_PHP_VERSION=${PHP_VERSION} - LARADOCK_PHALCON_VERSION=${PHALCON_VERSION} - INSTALL_XDEBUG=${PHP_FPM_INSTALL_XDEBUG} + - INSTALL_PCOV=${PHP_FPM_INSTALL_PCOV} - INSTALL_PHPDBG=${PHP_FPM_INSTALL_PHPDBG} - INSTALL_BLACKFIRE=${INSTALL_BLACKFIRE} - INSTALL_SSH2=${PHP_FPM_INSTALL_SSH2} diff --git a/env-example b/env-example index 0e80c21b..39dd35cb 100644 --- a/env-example +++ b/env-example @@ -97,6 +97,7 @@ WORKSPACE_INSTALL_PHPREDIS=true WORKSPACE_INSTALL_WORKSPACE_SSH=false WORKSPACE_INSTALL_SUBVERSION=false WORKSPACE_INSTALL_XDEBUG=false +WORKSPACE_INSTALL_PCOV=true WORKSPACE_INSTALL_PHPDBG=false WORKSPACE_INSTALL_SSH2=false WORKSPACE_INSTALL_LDAP=false @@ -157,6 +158,7 @@ PHP_FPM_INSTALL_IMAGE_OPTIMIZERS=true PHP_FPM_INSTALL_PHPREDIS=true PHP_FPM_INSTALL_MEMCACHED=false PHP_FPM_INSTALL_XDEBUG=false +PHP_FPM_INSTALL_PCOV=false PHP_FPM_INSTALL_XHPROF=false PHP_FPM_INSTALL_PHPDBG=false PHP_FPM_INSTALL_IMAP=false diff --git a/php-fpm/Dockerfile b/php-fpm/Dockerfile index 68a1933e..bc748698 100644 --- a/php-fpm/Dockerfile +++ b/php-fpm/Dockerfile @@ -164,6 +164,25 @@ RUN sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=1/" /usr/local/e sed -i "s/xdebug.remote_enable=0/xdebug.remote_enable=1/" /usr/local/etc/php/conf.d/xdebug.ini && \ sed -i "s/xdebug.cli_color=0/xdebug.cli_color=1/" /usr/local/etc/php/conf.d/xdebug.ini +########################################################################### +# pcov: +########################################################################### + +USER root + +ARG INSTALL_PCOV=false + +RUN if [ ${INSTALL_PCOV} = true ]; then \ + if [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ]; then \ + if [ $(php -r "echo PHP_MAJOR_VERSION;") != "0" ]; then \ + pecl install pcov && \ + echo "extension=pcov.so" >> /etc/php/${LARADOCK_PHP_VERSION}/cli/php.ini && \ + echo "pcov.enabled" >> /etc/php/${LARADOCK_PHP_VERSION}/cli/php.ini \ + ;fi \ + ;fi \ +;fi + + ########################################################################### # Phpdbg: ########################################################################### diff --git a/workspace/Dockerfile b/workspace/Dockerfile index cbbeb2e9..788244bd 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -324,6 +324,25 @@ RUN sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=1/" /etc/php/${L sed -i "s/xdebug.remote_enable=0/xdebug.remote_enable=1/" /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \ sed -i "s/xdebug.cli_color=0/xdebug.cli_color=1/" /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/xdebug.ini +########################################################################### +# pcov: +########################################################################### + +USER root + +ARG INSTALL_PCOV=false + +RUN if [ ${INSTALL_PCOV} = true ]; then \ + if [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ]; then \ + if [ $(php -r "echo PHP_MAJOR_VERSION;") != "0" ]; then \ + pecl install pcov && \ + echo "extension=pcov.so" >> /etc/php/${LARADOCK_PHP_VERSION}/cli/php.ini && \ + echo "pcov.enabled" >> /etc/php/${LARADOCK_PHP_VERSION}/cli/php.ini \ + ;fi \ + ;fi \ +;fi + + ########################################################################### # Phpdbg: ########################################################################### From c2caf730db7459469cb23d1a3fbc91806047c849 Mon Sep 17 00:00:00 2001 From: Alec Joy Date: Sun, 4 Aug 2019 14:14:32 -0400 Subject: [PATCH 2/5] Accidentally left the PCOV env file to defaul true and moved Pcov documentation section below all xdebug entries --- DOCUMENTATION/content/documentation/index.md | 32 ++++++++++---------- env-example | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/DOCUMENTATION/content/documentation/index.md b/DOCUMENTATION/content/documentation/index.md index 55fbb1fd..79d2e416 100644 --- a/DOCUMENTATION/content/documentation/index.md +++ b/DOCUMENTATION/content/documentation/index.md @@ -299,6 +299,22 @@ For information on how to configure xDebug with your IDE and work it out, check +
+ +## Start/Stop xDebug: + +By installing xDebug, you are enabling it to run on startup by default. + +To control the behavior of xDebug (in the `php-fpm` Container), you can run the following commands from the Laradock root folder, (at the same prompt where you run docker-compose): + +- Stop xDebug from running by default: `.php-fpm/xdebug stop`. +- Start xDebug by default: `.php-fpm/xdebug start`. +- See the status: `.php-fpm/xdebug status`. + +Note: If `.php-fpm/xdebug` doesn't execute and gives `Permission Denied` error the problem can be that file `xdebug` doesn't have execution access. This can be fixed by running `chmod` command with desired access permissions. + + +
## Install pcov @@ -322,22 +338,6 @@ of the [README](https://github.com/krakjoe/pcov) -
- -## Start/Stop xDebug: - -By installing xDebug, you are enabling it to run on startup by default. - -To control the behavior of xDebug (in the `php-fpm` Container), you can run the following commands from the Laradock root folder, (at the same prompt where you run docker-compose): - -- Stop xDebug from running by default: `.php-fpm/xdebug stop`. -- Start xDebug by default: `.php-fpm/xdebug start`. -- See the status: `.php-fpm/xdebug status`. - -Note: If `.php-fpm/xdebug` doesn't execute and gives `Permission Denied` error the problem can be that file `xdebug` doesn't have execution access. This can be fixed by running `chmod` command with desired access permissions. - - -
## Install phpdbg diff --git a/env-example b/env-example index 39dd35cb..3861cd7b 100644 --- a/env-example +++ b/env-example @@ -97,7 +97,7 @@ WORKSPACE_INSTALL_PHPREDIS=true WORKSPACE_INSTALL_WORKSPACE_SSH=false WORKSPACE_INSTALL_SUBVERSION=false WORKSPACE_INSTALL_XDEBUG=false -WORKSPACE_INSTALL_PCOV=true +WORKSPACE_INSTALL_PCOV=false WORKSPACE_INSTALL_PHPDBG=false WORKSPACE_INSTALL_SSH2=false WORKSPACE_INSTALL_LDAP=false From 47bb995cad1fb16c5e1dff001b917ad3f9c6a608 Mon Sep 17 00:00:00 2001 From: Alec Joy Date: Mon, 5 Aug 2019 09:53:36 -0400 Subject: [PATCH 3/5] Typo in PHP version check --- workspace/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workspace/Dockerfile b/workspace/Dockerfile index 788244bd..c70be919 100644 --- a/workspace/Dockerfile +++ b/workspace/Dockerfile @@ -334,7 +334,7 @@ ARG INSTALL_PCOV=false RUN if [ ${INSTALL_PCOV} = true ]; then \ if [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ]; then \ - if [ $(php -r "echo PHP_MAJOR_VERSION;") != "0" ]; then \ + if [ $(php -r "echo PHP_MINOR_VERSION;") != "0" ]; then \ pecl install pcov && \ echo "extension=pcov.so" >> /etc/php/${LARADOCK_PHP_VERSION}/cli/php.ini && \ echo "pcov.enabled" >> /etc/php/${LARADOCK_PHP_VERSION}/cli/php.ini \ From bdf2a285a7d9f7d036794b410e85f97ee61aa8c0 Mon Sep 17 00:00:00 2001 From: Alec Joy Date: Mon, 5 Aug 2019 09:54:15 -0400 Subject: [PATCH 4/5] Typo in PHP Version check --- php-fpm/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php-fpm/Dockerfile b/php-fpm/Dockerfile index bc748698..59d64b9e 100644 --- a/php-fpm/Dockerfile +++ b/php-fpm/Dockerfile @@ -174,7 +174,7 @@ ARG INSTALL_PCOV=false RUN if [ ${INSTALL_PCOV} = true ]; then \ if [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ]; then \ - if [ $(php -r "echo PHP_MAJOR_VERSION;") != "0" ]; then \ + if [ $(php -r "echo PHP_MINOR_VERSION;") != "0" ]; then \ pecl install pcov && \ echo "extension=pcov.so" >> /etc/php/${LARADOCK_PHP_VERSION}/cli/php.ini && \ echo "pcov.enabled" >> /etc/php/${LARADOCK_PHP_VERSION}/cli/php.ini \ From ff640a0ca2070b3e02773959504232a1ec494231 Mon Sep 17 00:00:00 2001 From: Alec Joy Date: Mon, 5 Aug 2019 10:45:12 -0400 Subject: [PATCH 5/5] Use docker command to enable pcov --- php-fpm/Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/php-fpm/Dockerfile b/php-fpm/Dockerfile index 59d64b9e..527d9c45 100644 --- a/php-fpm/Dockerfile +++ b/php-fpm/Dockerfile @@ -176,8 +176,7 @@ RUN if [ ${INSTALL_PCOV} = true ]; then \ if [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ]; then \ if [ $(php -r "echo PHP_MINOR_VERSION;") != "0" ]; then \ pecl install pcov && \ - echo "extension=pcov.so" >> /etc/php/${LARADOCK_PHP_VERSION}/cli/php.ini && \ - echo "pcov.enabled" >> /etc/php/${LARADOCK_PHP_VERSION}/cli/php.ini \ + docker-php-ext-enable pcov \ ;fi \ ;fi \ ;fi