Browse Source

Added support for Xdebug + VS Code

Mark Shust 6 years ago
parent
commit
f1f5c84018

+ 13 - 0
CHANGELOG.md

@@ -8,7 +8,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
 
 - New PHP 7.2 image is now available on the dev tag. Please report any issues.
 
+## [17.0.0] - 2018-09-06
+
+### Removed
+- Removed idekey setting from php.ini config.
+
+### Changed
+- Simplified Xdebug configuration for PHPStorm. This will require configuration updates for all users using Xdebug within PHPStorm.
+
+### Added
+- Added support for Xdebug and VS Code.
+
 ## [16.2.0] - 2018-08-29
+
+### Changed
 - Updated docker-compose.yml file to volume mount vendor folder for 50% performance increase
 
 ## [16.1.0] - 2018-08-23

+ 33 - 17
README.md

@@ -147,21 +147,15 @@ See the `compose` folder for sample setups for both Magento 1 and Magento 2. Bas
 
 - The hostname of each service is the name of the service within the `docker-compose.yml` file. So for example, MySQL's hostname is `db` (not `localhost`) when accessing it from a Docker container.
 
-### PHPStorm & Xdebug
+### Xdebug & PHPStorm
 
-First, enable Xdebug in the PHP-FPM container by running: `bin/xdebug enable`, the restart the docker containers (CTRL+C, `bin/start`).
+First, enable Xdebug in the PHP-FPM container by running: `bin/xdebug enable`, the restart the docker containers (CTRL+C then `bin/start`).
 
 Then, open `PHPStorm > Preferences > Languages & Frameworks > PHP` and configure:
 
 - `CLI Interpreter`:
-  - Create a new interpreter and specify `From Docker`, and name it `phpfpm`.
-  - Choose `Docker`, then select the `markoshust/magento-php:7-0-fpm` image name, and set the `PHP Executable` to `php`.
-  - Under `Additional > Debugger Extension`, enter
-    - for PHP 5.6: `/usr/local/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so`
-    - for PHP 7.0: `/usr/local/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so`
-    - for PHP 7.1: `/usr/local/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so`
-    - for PHP 7.2: `/usr/local/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so`
-  - Hitting the reload executable button should find the correct PHP Version and Xdebug debugger configuration.
+  - Create a new interpreter and specify `From Docker`, and name it `markoshust/magento-php:7-1-fpm`.
+  - Choose `Docker`, then select the `markoshust/magento-php:7-1-fpm` image name, and set the `PHP Executable` to `php`.
 
 - `Path mappings`:
   - Don't do anything here as the next `Docker container` step will automatically setup a path mapping from `/var/www/html` to `./src`.
@@ -172,11 +166,7 @@ Then, open `PHPStorm > Preferences > Languages & Frameworks > PHP` and configure
 
 Open `PHPStorm > Preferences > Languages & Frameworks > PHP > Debug` and set Debug Port to `9001`.
 
-Open `PHPStorm > Preferences > Languages & Frameworks > PHP > DBGp Proxy` and set:
-
-- IDE key: `PHPSTORM`
-- Host: `10.254.254.254`
-- Port: `9001`
+Open `PHPStorm > Preferences > Languages & Frameworks > PHP > DBGp Proxy` and set Port to `9001`.
 
 Open `PHPStorm > Preferences > Languages & Frameworks > PHP > Servers` and create a new server:
 
@@ -184,9 +174,35 @@ Open `PHPStorm > Preferences > Languages & Frameworks > PHP > Servers` and creat
 - Set Port to `8000`
 - Check the Path Mappings box and map `src` to the absolute path of `/var/www/html`
 
-Create a new `PHP Remote Debug` configuration at `Run > Edit Configurations`. Set the Name to your domain (ex. `magento2.test`). Check `Filter debug connection by IDE Key`, select the server of your domain name (ex. `magento2.test`), and set IDE key to `PHPSTORM`. The `Validate` functionality will most likely not work with the Docker container, but doesn't affect the ability to use Xdebug.
+Create a new `PHP Remote Debug` configuration at `Run > Edit Configurations`. Set the Name to your domain (ex. `magento2.test`), then click OK.
+
+Open up `src/pub/index.php`, and set a breakpoint near the end of the file. Go to `Run > Debug 'magento2.test'`, and open up a web browser. Xdebug within PHPStorm should now enable the debugger and stop at the toggled breakpoint.
+
+### Xdebug & VS Code
+
+Install and enable the PHP Debug extension from the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug).
+
+Create or edit the file at `.vscode/launch.json`:
+
+```
+{
+  "version": "0.2.0",
+  "configurations": [
+    {
+      "name": "Listen for XDebug",
+      "type": "php",
+      "request": "launch",
+      "pathMappings": {
+        "/var/www/html": "${workspaceFolder}/src"
+      },
+      "port": 9001
+    }
+  ]
+}
+```
+
+Open up `src/pub/index.php`, and set a breakpoint near the end of the file. Go to `Debug > Start Debugging`, and open up a web browser. Xdebug within VS Code should now enable the debugger and stop at the toggled breakpoint.
 
-Open up `src/pub/index.php`, and set a breakpoint near the end of the file. Go to `Run > Debug 'magento2.test'`, and open up a web browser. Be sure to install a plugin like [Xdebug helper](https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc) which sets the IDE key to `PHPStorm` automatically for you. Enable the browser extension and activate it on the site, and reload the site. Xdebug within PHPStorm should now enable the debugger and stop at the toggled breakpoint.
 
 ### Composer Authentication
 

+ 3 - 3
compose/magento-2-windows/docker-compose.yml

@@ -1,5 +1,5 @@
 # Mark Shust's Docker Configuration for Magento (https://github.com/markoshust/docker-magento)
-# Version 16.2.0
+# Version 17.0.0
 
 version: "3"
 
@@ -19,14 +19,14 @@ services:
       - appdata:/var/www/html/vendor
 
   phpfpm:
-    image: markoshust/magento-php:7.1-fpm-7
+    image: markoshust/magento-php:7.1-fpm-8
     links:
       - db
     volumes: *appvolumes
 
   # Disabling cron by default as it uses higher CPU, enable if needed
   #cron:
-  #  image: markoshust/magento-php:7.1-fpm-7
+  #  image: markoshust/magento-php:7.1-fpm-8
   #  user: root
   #  command: /usr/local/bin/cronstart
   #  tty: true

+ 3 - 3
compose/magento-2/docker-compose.yml

@@ -1,5 +1,5 @@
 # Mark Shust's Docker Configuration for Magento (https://github.com/markoshust/docker-magento)
-# Version 16.2.0
+# Version 17.0.0
 
 version: "3"
 
@@ -19,14 +19,14 @@ services:
       - appdata:/var/www/html/vendor
 
   phpfpm:
-    image: markoshust/magento-php:7.1-fpm-7
+    image: markoshust/magento-php:7.1-fpm-8
     links:
       - db
     volumes: *appvolumes
 
   # Disabling cron by default as it uses higher CPU, enable if needed
   #cron:
-  #  image: markoshust/magento-php:7.1-fpm-7
+  #  image: markoshust/magento-php:7.1-fpm-8
   #  user: root
   #  command: /usr/local/bin/cronstart
   #  tty: true

+ 0 - 2
images/php/7.0/conf/php.ini

@@ -4,9 +4,7 @@ zlib.output_compression = On
 cgi.fix_pathinfo = 0
 date.timezone = UTC
 
-xdebug.idekey = PHPSTORM
 xdebug.remote_autostart = 1
-xdebug.remote_connect_back = 0
 xdebug.remote_enable = 1
 xdebug.remote_host = 10.254.254.254
 xdebug.remote_port = 9001

+ 0 - 2
images/php/7.1/conf/php.ini

@@ -4,9 +4,7 @@ zlib.output_compression = On
 cgi.fix_pathinfo = 0
 date.timezone = UTC
 
-xdebug.idekey = PHPSTORM
 xdebug.remote_autostart = 1
-xdebug.remote_connect_back = 0
 xdebug.remote_enable = 1
 xdebug.remote_host = 10.254.254.254
 xdebug.remote_port = 9001

+ 0 - 2
images/php/7.2/conf/php.ini

@@ -4,9 +4,7 @@ zlib.output_compression = On
 cgi.fix_pathinfo = 0
 date.timezone = UTC
 
-xdebug.idekey = PHPSTORM
 xdebug.remote_autostart = 1
-xdebug.remote_connect_back = 0
 xdebug.remote_enable = 1
 xdebug.remote_host = 10.254.254.254
 xdebug.remote_port = 9001