Martino Massalini преди 2 години
родител
ревизия
9d9e993ffd
променени са 2 файла, в които са добавени 11 реда и са изтрити 10 реда
  1. 1 1
      README.md
  2. 10 9
      compose/bin/debug-cli

+ 1 - 1
README.md

@@ -251,7 +251,7 @@ It is recommended to keep your root docker config files in one repository, and y
 - `bin/devconsole`: Alias for `bin/n98-magerun2 dev:console`
 - `bin/docker-compose`: Support V1 (`docker-compose`) and V2 (`docker compose`) docker compose command, and use custom configuration files, such as `compose.yml` and `compose.dev.yml`
 - `bin/download`: Download specific Magento version from Composer to the container, with optional arguments of the version (2.4.5-p1 [default]) and type ("community" [default], "enterprise", or "mageos"). Ex. `bin/download 2.4.5-p1 enterprise`
-- `bin/debug-cli`: Enable xdebug for Magento Console Command. Second argument is optional, default is PHPSTORM Ex. `bin/debug-cli enable [PHPSTORM]`
+- `bin/debug-cli`: Enable Xdebug for bin/magento, with an optional argument of the IDE key. Defaults to PHPSTORM Ex. `bin/debug-cli enable PHPSTORM`
 - `bin/fixowns`: This will fix filesystem ownerships within the container.
 - `bin/fixperms`: This will fix filesystem permissions within the container.
 - `bin/grunt`: Run the grunt binary. Ex. `bin/grunt exec`

+ 10 - 9
compose/bin/debug-cli

@@ -1,11 +1,5 @@
 #!/bin/bash
 S=$(bin/clinotty cat /usr/local/etc/php/php.ini | grep -iGc 'xdebug.mode = off');
-
-if [[ $S == 1 ]]; then
-  echo "Enable xdebug first"
-  exit 1
-fi
-
 R=$(cat ./env/phpfpm.env | grep -c 'XDEBUG_CONFIG=idekey')
 
 if [[ -z "$2" ]]
@@ -32,22 +26,29 @@ local_debug_toggle() {
 }
 
 local_debug_enable() {
+  if [[ $S == 1 ]]; then
+    bin/xdebug enable
+  fi
+
   if [[ $R == 1 ]]; then
     echo "Already enabled"
     exit 0
   fi
+
   echo "XDEBUG_CONFIG=idekey=$platform" >> ./env/phpfpm.env
+  sleep 1
+  bin/restart phpfpm
   echo "Cli debug enabled"
 }
 
 local_debug_disable() {
   sed -i '' '/XDEBUG_CONFIG=idekey/d' ./env/phpfpm.env
+  sleep 1
+  bin/restart phpfpm
   echo "Cli debug disabled"
 }
 
 firstArgLetter="$(echo "$1" | head -c 1)"
-
-
 if [[ $firstArgLetter == "d" ]]; then
   local_debug_disable
 elif [[ $firstArgLetter == "e" ]]; then
@@ -58,4 +59,4 @@ elif [[ $firstArgLetter == "s" ]]; then
   local_debug_status
 else
     printf "Please specify either 'disable', 'enable', 'status' or 'toggle' as mandatory argument.\nSpecify as an optional second argument the platform. Default is PHPSTORM\nEx: bin/debug-cli enable [PHPSTORM]\n"
-fi
+fi