Skip to content

Commit cc1d6aa

Browse files
authored
Merge pull request laradock#2226 from ajoy39/master
Add support for pcov code coverage driver
2 parents a9f84bf + ff640a0 commit cc1d6aa

5 files changed

Lines changed: 64 additions & 0 deletions

File tree

DOCUMENTATION/content/documentation/index.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,29 @@ Note: If `.php-fpm/xdebug` doesn't execute and gives `Permission Denied` error t
314314

315315

316316

317+
<br>
318+
<a name="Install-pcov"></a>
319+
## Install pcov
320+
321+
1 - First install `pcov` in the Workspace and the PHP-FPM Containers:
322+
<br>
323+
a) open the `.env` file
324+
<br>
325+
b) search for the `WORKSPACE_INSTALL_PCOV` argument under the Workspace Container
326+
<br>
327+
c) set it to `true`
328+
<br>
329+
d) search for the `PHP_FPM_INSTALL_PCOV` argument under the PHP-FPM Container
330+
<br>
331+
e) set it to `true`
332+
333+
2 - Re-build the containers `docker-compose build workspace php-fpm`
334+
335+
Note that pcov is only supported on PHP 7.1 or newer. For more information on setting up pcov optimally, check the recommended section
336+
of the [README](https://github.com/krakjoe/pcov)
337+
338+
339+
317340
<br>
318341
<a name="Install-phpdbg"></a>
319342
## Install phpdbg

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ services:
6565
- LARADOCK_PHALCON_VERSION=${PHALCON_VERSION}
6666
- INSTALL_SUBVERSION=${WORKSPACE_INSTALL_SUBVERSION}
6767
- INSTALL_XDEBUG=${WORKSPACE_INSTALL_XDEBUG}
68+
- INSTALL_PCOV=${WORKSPACE_INSTALL_PCOV}
6869
- INSTALL_PHPDBG=${WORKSPACE_INSTALL_PHPDBG}
6970
- INSTALL_BLACKFIRE=${INSTALL_BLACKFIRE}
7071
- INSTALL_SSH2=${WORKSPACE_INSTALL_SSH2}
@@ -166,6 +167,7 @@ services:
166167
- LARADOCK_PHP_VERSION=${PHP_VERSION}
167168
- LARADOCK_PHALCON_VERSION=${PHALCON_VERSION}
168169
- INSTALL_XDEBUG=${PHP_FPM_INSTALL_XDEBUG}
170+
- INSTALL_PCOV=${PHP_FPM_INSTALL_PCOV}
169171
- INSTALL_PHPDBG=${PHP_FPM_INSTALL_PHPDBG}
170172
- INSTALL_BLACKFIRE=${INSTALL_BLACKFIRE}
171173
- INSTALL_SSH2=${PHP_FPM_INSTALL_SSH2}

env-example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ WORKSPACE_INSTALL_PHPREDIS=true
101101
WORKSPACE_INSTALL_WORKSPACE_SSH=false
102102
WORKSPACE_INSTALL_SUBVERSION=false
103103
WORKSPACE_INSTALL_XDEBUG=false
104+
WORKSPACE_INSTALL_PCOV=false
104105
WORKSPACE_INSTALL_PHPDBG=false
105106
WORKSPACE_INSTALL_SSH2=false
106107
WORKSPACE_INSTALL_LDAP=false
@@ -168,6 +169,7 @@ PHP_FPM_INSTALL_IMAGE_OPTIMIZERS=true
168169
PHP_FPM_INSTALL_PHPREDIS=true
169170
PHP_FPM_INSTALL_MEMCACHED=false
170171
PHP_FPM_INSTALL_XDEBUG=false
172+
PHP_FPM_INSTALL_PCOV=false
171173
PHP_FPM_INSTALL_XHPROF=false
172174
PHP_FPM_INSTALL_PHPDBG=false
173175
PHP_FPM_INSTALL_IMAP=false

php-fpm/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,24 @@ RUN sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=1/" /usr/local/e
173173
sed -i "s/xdebug.remote_enable=0/xdebug.remote_enable=1/" /usr/local/etc/php/conf.d/xdebug.ini && \
174174
sed -i "s/xdebug.cli_color=0/xdebug.cli_color=1/" /usr/local/etc/php/conf.d/xdebug.ini
175175

176+
###########################################################################
177+
# pcov:
178+
###########################################################################
179+
180+
USER root
181+
182+
ARG INSTALL_PCOV=false
183+
184+
RUN if [ ${INSTALL_PCOV} = true ]; then \
185+
if [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ]; then \
186+
if [ $(php -r "echo PHP_MINOR_VERSION;") != "0" ]; then \
187+
pecl install pcov && \
188+
docker-php-ext-enable pcov \
189+
;fi \
190+
;fi \
191+
;fi
192+
193+
176194
###########################################################################
177195
# Phpdbg:
178196
###########################################################################

workspace/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,25 @@ RUN sed -i "s/xdebug.remote_autostart=0/xdebug.remote_autostart=1/" /etc/php/${L
342342
sed -i "s/xdebug.remote_enable=0/xdebug.remote_enable=1/" /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/xdebug.ini && \
343343
sed -i "s/xdebug.cli_color=0/xdebug.cli_color=1/" /etc/php/${LARADOCK_PHP_VERSION}/cli/conf.d/xdebug.ini
344344

345+
###########################################################################
346+
# pcov:
347+
###########################################################################
348+
349+
USER root
350+
351+
ARG INSTALL_PCOV=false
352+
353+
RUN if [ ${INSTALL_PCOV} = true ]; then \
354+
if [ $(php -r "echo PHP_MAJOR_VERSION;") = "7" ]; then \
355+
if [ $(php -r "echo PHP_MINOR_VERSION;") != "0" ]; then \
356+
pecl install pcov && \
357+
echo "extension=pcov.so" >> /etc/php/${LARADOCK_PHP_VERSION}/cli/php.ini && \
358+
echo "pcov.enabled" >> /etc/php/${LARADOCK_PHP_VERSION}/cli/php.ini \
359+
;fi \
360+
;fi \
361+
;fi
362+
363+
345364
###########################################################################
346365
# Phpdbg:
347366
###########################################################################

0 commit comments

Comments
 (0)