Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit c97ff58

Browse files
authored
Merge pull request Varying-Vagrant-Vagrants#2702 from Varying-Vagrant-Vagrants/better_debug_switch_checks
improve the output and some checks on the debug switching script
2 parents 90d1a6b + 34ef09c commit c97ff58

File tree

4 files changed

+46
-19
lines changed

4 files changed

+46
-19
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ permalink: /docs/en-US/changelog/
1717
* Better error messages with links to docs when trying to use a PHP version that isn't installed ( #2689 )
1818
* Opted out of Dotnet package telemetry ( #2689 )
1919
* Replace references to the Squizlab PHPCS with that from the PHPCS Standards org ( #2692 )
20+
* Better PHP Debug mod switching outputs and checks ( #2702 )
21+
* PHP Info and Xdebug info pages now state their versions ( #2702 )
2022

2123
### Bug Fixes
2224

config/homebin/switch_php_debugmod

+40-14
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,21 @@ disable_phpmods() {
2828
for phpv in $(phpquery -V)
2929
do
3030
if is_module_enabled_fpm "${phpv}" "${i}"; then
31-
vvv_info " ✘ Disabling active PHP <b>v${phpv}</b><info> debug mod: </info><b>'${i}'</b>"
32-
sudo phpdismod -q -s fpm -v "${phpv}" "${i}"
33-
sudo phpdismod -q -s cli -v "${phpv}" "${i}"
31+
#vvv_info " ✘ Disabling active PHP <b>v${phpv}</b><info> debug mod: </info><b>'${i}'</b>"
32+
#sudo phpdismod -q -s fpm -v "${phpv}" "${i}"
33+
#sudo phpdismod -q -s cli -v "${phpv}" "${i}"
34+
35+
if sudo phpdismod -q -v "${phpv}" -s fpm "${i}"; then
36+
vvv_success " - ✔ Disabled ${i} for PHP <b>v${phpv} FPM</b>"
37+
else
38+
vvv_error " - x Could not disable ${i} for PHP <b>v${phpv} FPM</b>"
39+
fi
40+
41+
if sudo phpdismod -q -v "${phpv}" -s cli "${i}"; then
42+
vvv_success " - ✔ Disabled ${i} for PHP <b>v${phpv} CLI</b>"
43+
else
44+
vvv_error " - x Could not disable ${i} for PHP <b>v${phpv} CLI</b>"
45+
fi
3446
fi
3547
done
3648
done
@@ -40,11 +52,19 @@ enable_phpmod() {
4052
for phpv in $(phpquery -V)
4153
do
4254
if is_module_installed_fpm "${phpv}" "${1}"; then
43-
vvv_info " * Enabling <b>'${1}'</b><info> for PHP <b>v${phpv}</b>"
44-
sudo phpenmod -q -v "${phpv}" -s fpm "${1}"
45-
sudo phpenmod -q -v "${phpv}" -s cli "${1}"
55+
if sudo phpenmod -q -v "${phpv}" -s fpm "${1}"; then
56+
vvv_success " - ✔ Enabled ${1} for PHP <b>v${phpv} FPM</b>"
57+
else
58+
vvv_error " - x Could not enable ${1} for PHP <b>v${phpv} FPM</b>"
59+
fi
60+
61+
if sudo phpenmod -q -v "${phpv}" -s cli "${1}"; then
62+
vvv_success " - ✔ Enabled ${1} for PHP <b>v${phpv} CLI</b>"
63+
else
64+
vvv_error " - x Could not enable ${1} for PHP <b>v${phpv} CLI</b>"
65+
fi
4666
else
47-
vvv_info " * Skipped enabling ${1} in PHP <b>v${phpv}</b><info>, module isn't installed for this version"
67+
vvv_info " - ? Skipped enabling ${1} in PHP <b>v${phpv}</b><info>, module isn't installed for this version"
4868
fi
4969
done
5070
}
@@ -65,9 +85,19 @@ is_module_installed_fpm() {
6585

6686
restart_phpfpm() {
6787
vvv_info " * Restarting PHP FPM services so that the change takes effect"
68-
find /etc/init.d/ -name "php*-fpm" -exec bash -c 'sudo service "$(basename "$0")" restart' {} \;
88+
if find /etc/init.d/ -name "php*-fpm" -exec bash -c 'sudo service "$(basename "$0")" restart' {} \;; then
89+
vvv_success " ✔ Completed restart sequence"
90+
else
91+
vvv_error " x One of the PHP services failed to restart, changes may not take effect."
92+
fi
6993
}
7094

95+
96+
vvv_info "Attempting to disable PHP debug mods and switch to <b>${mod}</b><info>:"
97+
if [[ "${mod}" == "pcov" ]]; then
98+
vvv_info " * pcov supports PHP 7.1 and above, it is not available for 5.6 and 7.0"
99+
fi
100+
71101
disable_phpmods phpmods[@]
72102

73103
if [[ "${mod}" == "none" ]]; then
@@ -76,10 +106,6 @@ if [[ "${mod}" == "none" ]]; then
76106
exit 0
77107
fi
78108

79-
if [[ "${mod}" == "pcov" ]]; then
80-
vvv_info " * pcov supports PHP 7.1 and above, it is not available for 5.6 and 7.0"
81-
fi
82-
83109
# Tideways needs 2 mods enabling
84110
if [[ "${mod}" == "tideways" ]]; then
85111
enable_phpmod "xhgui"
@@ -91,11 +117,11 @@ fi
91117

92118
if [[ "${mod}" == "xdebug" ]]; then
93119
# Ensure the log file for xdebug is group writeable.
94-
vvv_info " * Making sure log/php/xdebug-remote.log is readable and present"
120+
vvv_info " * Making sure <b>log/php/xdebug-remote.log</b><info> is readable and present"
95121
sudo touch /var/log/php/xdebug-remote.log
96122
sudo chmod 664 /var/log/php/xdebug-remote.log
97123
fi
98124

99125
enable_phpmod "${mod}"
100126
restart_phpfpm
101-
vvv_success " ✔ PHP Debug mod switch to <b>${mod}</b><success> on all available PHP versions complete.</success>"
127+
vvv_info " ✔ PHP Debug mod switch to <b>${mod}</b><success> on all available PHP versions complete.</success>"

www/default/phpinfo/index.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
*/
55
?>
66
<nav class="center">
7-
<a href="//vvv.test/phpinfo/">PHP Info</a>
7+
<a href="//vvv.test/phpinfo/">PHP Info (v<?php echo phpversion(); ?>)</a>
88
<?php
99
if ( function_exists( 'xdebug_info' ) ) {
10-
?>&middot; <a href="//vvv.test/xdebuginfo/">Xdebug Info</a><?php
10+
?>&middot; <a href="//vvv.test/xdebuginfo/">Xdebug Info (v<?php echo phpversion('xdebug'); ?>)</a><?php
1111
}
1212
?>
1313
</nav>

www/default/xdebuginfo/index.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
?>
66
<style type="text/css">
77
body {
8-
color: #222;
98
font-family: sans-serif;
109
}
1110

@@ -25,10 +24,10 @@
2524
}
2625
</style>
2726
<nav class="center">
28-
<a href="//vvv.test/phpinfo/">PHP Info</a>
27+
<a href="//vvv.test/phpinfo/">PHP Info (v<?php echo phpversion(); ?>)</a>
2928
<?php
3029
if ( function_exists( 'xdebug_info' ) ) {
31-
?>&middot; <a href="//vvv.test/xdebuginfo/">Xdebug Info</a><?php
30+
?>&middot; <a href="//vvv.test/xdebuginfo/">Xdebug Info (v<?php echo phpversion('xdebug'); ?>)</a><?php
3231
}
3332
?>
3433
</nav>

0 commit comments

Comments
 (0)