Skip to content

Commit

Permalink
49.0.0 (#1277)
Browse files Browse the repository at this point in the history
  • Loading branch information
markshust authored Jan 15, 2025
1 parent 056b55e commit 6a4fbd2
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 43 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [49.0.0] - 2024-01-15

### Updated
- 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)

## [48.0.1] - 2024-12-07

### Fixed
Expand Down
84 changes: 42 additions & 42 deletions compose/bin/xdebug
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
#!/usr/bin/env bash

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

xdebug_status() {
if [[ $S == 1 ]]; then
echo "Xdebug debug mode is disabled."
else
echo "Xdebug debug mode is enabled."
fi
display_modes() {
echo "- off"
echo "- develop"
echo "- coverage"
echo "- debug"
echo "- gcstats"
echo "- profile"
echo "- trace"
echo ""
printf "You can also combine multiple modes with commas (e.g., develop,trace)\n"
}

xdebug_toggle() {
if [[ $S == 1 ]]; then
xdebug_enable
else
xdebug_disable
fi
}
xdebug_set_mode() {
local new_mode=$1

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

xdebug_disable() {
if [[ $S == 0 ]]; then
bin/root sed -i -e 's/^xdebug.mode = debug/xdebug.mode = off/g' /usr/local/etc/php/php.ini
bin/cli kill -USR2 1
echo "Xdebug debug mode has been disabled."
else
echo "Xdebug debug mode is already disabled."
if [ "$current_mode" = "$new_mode" ]; then
echo "Current setting is already: xdebug.mode = $new_mode"
return 0
fi

bin/root sed -i -e "s/^xdebug\.mode.*$/xdebug.mode = $new_mode/g" /usr/local/etc/php/php.ini
bin/cli kill -USR2 1
echo "New setting: xdebug.mode = $new_mode"
}

firstArgLetter="$(echo "$1" | head -c 1)"

if [[ $firstArgLetter == "d" ]]; then
xdebug_disable
elif [[ $firstArgLetter == "e" ]]; then
xdebug_enable
elif [[ $firstArgLetter == "t" ]]; then
xdebug_toggle
elif [[ $firstArgLetter == "s" ]]; then
xdebug_status
else
printf "Please specify either 'disable', 'enable', 'status' or 'toggle' as an argument.\nEx: bin/xdebug status\n"
if [ -z "$1" ]; then
printf "Current setting: xdebug.mode = %s\n\n" "$current_mode"
printf "Update it by passing in a valid mode as an argument:\n"
display_modes
exit 1
fi

xdebug_set_mode "$1"
2 changes: 1 addition & 1 deletion compose/compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Mark Shust's Docker Configuration for Magento
## (https://github.com/markshust/docker-magento)
##
## Version 48.0.1
## Version 49.0.0

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

0 comments on commit 6a4fbd2

Please sign in to comment.