Selaa lähdekoodia

Xdebug 3 support #390

Mark Shust 4 vuotta sitten
vanhempi
commit
089bcbf3a4

+ 1 - 5
compose/.vscode/launch.json

@@ -1,5 +1,4 @@
 {
-  "version": "0.2.0",
   "configurations": [
     {
       "name": "Listen for XDebug",
@@ -8,10 +7,7 @@
       "pathMappings": {
         "/var/www/html": "${workspaceFolder}"
       },
-      "port": 9001,
-      "xdebugSettings": {
-        "idekey": "VSCODE"
-      }
+      "port": 9003,
     }
   ]
 }

+ 0 - 99
compose/bin/setup-composer-auth

@@ -1,99 +0,0 @@
-#!/bin/bash
-
-GLOBAL_AUTH=~/.composer/auth.json
-PROJECT_AUTH=./src/auth.json
-NEED_AUTH=false
-
-hash composer 2>/dev/null && USE_COMPOSER=true
-hash python3 2>/dev/null && USE_PYTHON3=true
-
-[ ! $USE_COMPOSER ] && [ ! $USE_PYTHON3 ] && echo "Failed to setup composer auth, it needs composer or python3" && exit 1
-
-# Get composer auth: username and password
-if [ $USE_COMPOSER ]; then
-    COMPOSER_USER="http-basic.repo.magento.com.username"
-    COMPOSER_PASS="http-basic.repo.magento.com.password"
-
-    PUBLIC_KEY="$(composer config -g $COMPOSER_USER 2>/dev/null)"
-    PRIVATE_KEY="$(composer config -g $COMPOSER_PASS 2>/dev/null)"
-
-    if [ -z "$PUBLIC_KEY" ] || [ -z "$PRIVATE_KEY" ]; then
-        PUBLIC_KEY="$(composer config -d ./src $COMPOSER_USER 2>/dev/null)"
-        PRIVATE_KEY="$(composer config -d ./src $COMPOSER_PASS 2>/dev/null)"
-        NEED_AUTH=true
-    fi
-elif [ $USE_PYTHON3 ]; then
-    PY3_USER="import sys, json; print(json.load(sys.stdin)['http-basic']['repo.magento.com']['username'])"
-    PY3_PASS="import sys, json; print(json.load(sys.stdin)['http-basic']['repo.magento.com']['password'])"
-
-    if [ -f "$GLOBAL_AUTH" ]; then
-        PUBLIC_KEY=$(python3 -c "$PY3_USER" 2>/dev/null < "$GLOBAL_AUTH")
-        PRIVATE_KEY=$(python3 -c "$PY3_PASS" 2>/dev/null < "$GLOBAL_AUTH")
-    fi
-
-    if [ -z "$PUBLIC_KEY" ] || [ -z "$PRIVATE_KEY" ]; then
-        if [ -f "$PROJECT_AUTH" ]; then
-            PUBLIC_KEY=$(python3 -c "$PY3_USER" 2>/dev/null < "$PROJECT_AUTH")
-            PRIVATE_KEY=$(python3 -c "$PY3_PASS" 2>/dev/null < "$PROJECT_AUTH")
-            NEED_AUTH=true
-        fi
-    fi
-fi
-
-if [ -n "$PUBLIC_KEY" ] && [ -n "$PRIVATE_KEY" ] && [ $NEED_AUTH = false ]; then
-    echo "Global composer auth already exists" && exit
-fi
-
-# The last chance to enter manually
-if [ -z "$PUBLIC_KEY" ] || [ -z "$PRIVATE_KEY" ]; then
-    exec < /dev/tty
-    echo
-    echo "    Authentication required (repo.magento.com, public_key and private_key):"
-    read -r -p "        Username: " PUBLIC_KEY
-    read -r -p "        Password: " PRIVATE_KEY
-    echo
-    exec <&-
-fi
-
-if [ -z "$PUBLIC_KEY" ] || [ -z "$PRIVATE_KEY" ]; then
-    echo "Please enter composer auth for repo.magento.com" && exit 1
-fi
-
-# For docker-compose.yml setting: ~/.composer:/var/www/.composer:cached
-echo "Authentication will add to host composer global config ($GLOBAL_AUTH) for docker container"
-if [ $USE_COMPOSER ]; then
-    composer global config http-basic.repo.magento.com "$PUBLIC_KEY" "$PRIVATE_KEY"
-elif [ $USE_PYTHON3 ]; then
-    PY3_MERGE_AUTH="""
-import sys, json;
-
-data = json.load(sys.stdin)
-auth= {
-    'http-basic': {
-        'repo.magento.com': {
-            'username': '${PUBLIC_KEY}',
-            'password': '${PRIVATE_KEY}'
-        }
-    }
-}
-
-def merge(src, dest):
-    for key, val in src.items():
-        if isinstance(val, dict):
-            node = dest.setdefault(key, {})
-            merge(val, node)
-        else:
-            dest[key] = val
-    return dest
-
-print(json.dumps(merge(auth, data), indent=4))
-"""
-    if [ -f "$GLOBAL_AUTH" ]; then
-        mkdir -p "$(dirname "$GLOBAL_AUTH")"
-        echo "{}" > "$GLOBAL_AUTH"
-    fi
-    mv "$GLOBAL_AUTH" "$GLOBAL_AUTH.bak"
-    python3 -c "$PY3_MERGE_AUTH" > "$GLOBAL_AUTH" < "$GLOBAL_AUTH.bak"
-fi
-
-echo "Success to setup composer auth"

+ 9 - 9
compose/bin/xdebug

@@ -1,12 +1,12 @@
 #!/bin/bash
 
-S=$(bin/cli cat /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini | grep -iGc '^;');
+S=$(bin/cli cat /usr/local/etc/php/php.ini | grep -iGc 'xdebug.mode = off');
 
 xdebug_status() {
     if [[ $S == 1 ]]; then
-        echo "Xdebug is disabled."
+        echo "Xdebug debug mode is disabled."
     else
-        echo "Xdebug is enabled."
+        echo "Xdebug debug mode is enabled."
     fi
 }
 
@@ -20,23 +20,23 @@ xdebug_toggle() {
 
 xdebug_enable() {
     if [[ $S == 1 ]]; then
-        bin/cli sed -i -e 's/^\;zend_extension/zend_extension/g' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
+        bin/root sed -i -e 's/^xdebug.mode = off/xdebug.mode = debug/g' /usr/local/etc/php/php.ini
         sleep 1
         bin/restart phpfpm
-        echo "Xdebug has been enabled."
+        echo "Xdebug debug mode has been enabled."
     else
-        echo "Xdebug is already enabled."
+        echo "Xdebug debug mode is already enabled."
     fi
 }
 
 xdebug_disable() {
     if [[ $S == 0 ]]; then
-        bin/cli sed -i -e 's/^\zend_extension/;zend_extension/g' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
+        bin/root sed -i -e 's/^xdebug.mode = debug/xdebug.mode = off/g' /usr/local/etc/php/php.ini
         sleep 1
         bin/restart phpfpm
-        echo "Xdebug has been disabled."
+        echo "Xdebug debug mode has been disabled."
     else
-        echo "Xdebug is already disabled."
+        echo "Xdebug debug mode is already disabled."
     fi
 }
 

+ 2 - 3
images/php/7.3/Dockerfile

@@ -57,10 +57,9 @@ RUN cd /tmp \
   && docker-php-ext-enable ioncube
 
 RUN pecl channel-update pecl.php.net \
-  && pecl install xdebug-2.9.8
+  && pecl install xdebug
 
-RUN docker-php-ext-enable xdebug \
-  && sed -i -e 's/^zend_extension/\;zend_extension/g' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
+RUN docker-php-ext-enable xdebug
 
 ## Replace next lines with below commented out version once issue is resolved
 # https://github.com/php/pecl-networking-ssh2/pull/36

+ 2 - 4
images/php/7.3/conf/php.ini

@@ -4,10 +4,8 @@ zlib.output_compression = On
 cgi.fix_pathinfo = 0
 date.timezone = UTC
 
-xdebug.remote_autostart = 1
-xdebug.remote_enable = 1
-xdebug.remote_host = host.docker.internal
-xdebug.remote_port = 9001
+xdebug.mode = debug
+xdebug.client_host = host.docker.internal
 xdebug.idekey = PHPSTORM
 
 upload_max_filesize = 100M

+ 2 - 3
images/php/7.4/Dockerfile

@@ -57,10 +57,9 @@ RUN cd /tmp \
   && docker-php-ext-enable ioncube
 
 RUN pecl channel-update pecl.php.net \
-  && pecl install xdebug-2.9.8
+  && pecl install xdebug
 
-RUN docker-php-ext-enable xdebug \
-  && sed -i -e 's/^zend_extension/\;zend_extension/g' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
+RUN docker-php-ext-enable xdebug
 
 ## Replace next lines with below commented out version once issue is resolved
 # https://github.com/php/pecl-networking-ssh2/pull/36

+ 2 - 4
images/php/7.4/conf/php.ini

@@ -4,10 +4,8 @@ zlib.output_compression = On
 cgi.fix_pathinfo = 0
 date.timezone = UTC
 
-xdebug.remote_autostart = 1
-xdebug.remote_enable = 1
-xdebug.remote_host = host.docker.internal
-xdebug.remote_port = 9001
+xdebug.mode = off
+xdebug.client_host = host.docker.internal
 xdebug.idekey = PHPSTORM
 
 upload_max_filesize = 100M