Skip to content

Commit 6a4fbd2

Browse files
authoredJan 15, 2025··
49.0.0 (#1277)
1 parent 056b55e commit 6a4fbd2

File tree

3 files changed

+48
-43
lines changed

3 files changed

+48
-43
lines changed
 

‎CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [49.0.0] - 2024-01-15
8+
9+
### Updated
10+
- Enhanced `bin/xdebug` script with more comprehensive mode management and validation, supporting all Xdebug modes (off, develop, coverage, debug, gcstats, profile, trace) and combinations [PR #1276](https://github.com/markshust/docker-magento/pull/1276)
11+
712
## [48.0.1] - 2024-12-07
813

914
### Fixed

‎compose/bin/xdebug

+42-42
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
11
#!/usr/bin/env bash
22

3-
S=$(bin/clinotty cat /usr/local/etc/php/php.ini | grep -iGc 'xdebug.mode = off');
3+
current_mode=$(bin/clinotty cat /usr/local/etc/php/php.ini | grep '^xdebug.mode' | cut -d'=' -f2 | tr -d ' ')
44

5-
xdebug_status() {
6-
if [[ $S == 1 ]]; then
7-
echo "Xdebug debug mode is disabled."
8-
else
9-
echo "Xdebug debug mode is enabled."
10-
fi
5+
display_modes() {
6+
echo "- off"
7+
echo "- develop"
8+
echo "- coverage"
9+
echo "- debug"
10+
echo "- gcstats"
11+
echo "- profile"
12+
echo "- trace"
13+
echo ""
14+
printf "You can also combine multiple modes with commas (e.g., develop,trace)\n"
1115
}
1216

13-
xdebug_toggle() {
14-
if [[ $S == 1 ]]; then
15-
xdebug_enable
16-
else
17-
xdebug_disable
18-
fi
19-
}
17+
xdebug_set_mode() {
18+
local new_mode=$1
2019

21-
xdebug_enable() {
22-
if [[ $S == 1 ]]; then
23-
bin/root sed -i -e 's/^xdebug.mode = off/xdebug.mode = debug/g' /usr/local/etc/php/php.ini
24-
bin/cli kill -USR2 1
25-
echo "Xdebug debug mode has been enabled."
26-
else
27-
echo "Xdebug debug mode is already enabled."
28-
fi
29-
}
20+
# Validate the mode(s)
21+
IFS=',' read -ra MODES <<< "$new_mode"
22+
for mode in "${MODES[@]}"; do
23+
case $mode in
24+
off|develop|coverage|debug|gcstats|profile|trace)
25+
continue
26+
;;
27+
*)
28+
printf "Invalid mode: %s\n\n" "$mode"
29+
echo "Valid modes are:"
30+
display_modes
31+
return 1
32+
;;
33+
esac
34+
done
3035

31-
xdebug_disable() {
32-
if [[ $S == 0 ]]; then
33-
bin/root sed -i -e 's/^xdebug.mode = debug/xdebug.mode = off/g' /usr/local/etc/php/php.ini
34-
bin/cli kill -USR2 1
35-
echo "Xdebug debug mode has been disabled."
36-
else
37-
echo "Xdebug debug mode is already disabled."
36+
if [ "$current_mode" = "$new_mode" ]; then
37+
echo "Current setting is already: xdebug.mode = $new_mode"
38+
return 0
3839
fi
40+
41+
bin/root sed -i -e "s/^xdebug\.mode.*$/xdebug.mode = $new_mode/g" /usr/local/etc/php/php.ini
42+
bin/cli kill -USR2 1
43+
echo "New setting: xdebug.mode = $new_mode"
3944
}
4045

41-
firstArgLetter="$(echo "$1" | head -c 1)"
42-
43-
if [[ $firstArgLetter == "d" ]]; then
44-
xdebug_disable
45-
elif [[ $firstArgLetter == "e" ]]; then
46-
xdebug_enable
47-
elif [[ $firstArgLetter == "t" ]]; then
48-
xdebug_toggle
49-
elif [[ $firstArgLetter == "s" ]]; then
50-
xdebug_status
51-
else
52-
printf "Please specify either 'disable', 'enable', 'status' or 'toggle' as an argument.\nEx: bin/xdebug status\n"
46+
if [ -z "$1" ]; then
47+
printf "Current setting: xdebug.mode = %s\n\n" "$current_mode"
48+
printf "Update it by passing in a valid mode as an argument:\n"
49+
display_modes
50+
exit 1
5351
fi
52+
53+
xdebug_set_mode "$1"

‎compose/compose.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Mark Shust's Docker Configuration for Magento
22
## (https://github.com/markshust/docker-magento)
33
##
4-
## Version 48.0.1
4+
## Version 49.0.0
55

66
## To use SSH, see https://github.com/markshust/docker-magento#ssh
77
## Linux users, see https://github.com/markshust/docker-magento#linux

0 commit comments

Comments
 (0)
Please sign in to comment.