From 92a27d96d00d14fb169736fe52f64df4335497ea Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen@paragon-es.de>
Date: Sun, 21 Jun 2020 11:17:20 +0200
Subject: [PATCH] Disable PHP debugging by default and provide ahoy commands to
 turn on and off

---
 ahoy.debug.yml  | 16 ++++++++++++++++
 composer.json   |  4 ++++
 src/Handler.php |  2 +-
 3 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 ahoy.debug.yml

diff --git a/ahoy.debug.yml b/ahoy.debug.yml
new file mode 100644
index 0000000..24bd08f
--- /dev/null
+++ b/ahoy.debug.yml
@@ -0,0 +1,16 @@
+ahoyapi: v2
+commands:
+  on:
+    cmd: |
+      echo "PHP_DEBUG=1" >>.env
+      env -i $(cat .env | xargs) >.env
+      composer lakedrops:docker4drupal --no-interaction
+      ahoy d4d up
+    usage: Turn on PHP debugging
+  off:
+    cmd: |
+      echo "PHP_DEBUG=0" >>.env
+      env -i $(cat .env | xargs) >.env
+      composer lakedrops:docker4drupal --no-interaction
+      ahoy d4d up
+    usage: Turn off PHP debugging
diff --git a/composer.json b/composer.json
index a60ac4a..d1c9d20 100644
--- a/composer.json
+++ b/composer.json
@@ -54,6 +54,10 @@
                 "live": {
                     "usage": "Interact with the live site",
                     "imports": ["ahoy.live.yml"]
+                },
+                "debug": {
+                    "usage": "PHP debugging",
+                    "imports": ["ahoy.debug.yml"]
                 }
             }
         }
diff --git a/src/Handler.php b/src/Handler.php
index c4171ce..67a486f 100644
--- a/src/Handler.php
+++ b/src/Handler.php
@@ -261,7 +261,7 @@ class Handler extends BaseHandler {
         ],
         'php' => [
           'version' => $env->receiveGlobal('PHP_VERSION', 'PHP version', '7.2'),
-          'xdebug' => $this->isLocalDevMode() ? 1 : 0,
+          'xdebug' => $env->receiveGlobal('PHP_DEBUG', 'PHP debug', '0'),
         ],
         'webserver' => [
           'type' => 'apache',
-- 
GitLab