From 88c30ab9d0e81e10dbb36498ede648c147dcc452 Mon Sep 17 00:00:00 2001 From: Inge Amlien Date: Fri, 24 May 2024 10:11:38 +0000 Subject: [PATCH] Add xdebug to make_php, vscode xdebug launch prof Add vscode xdebug extension to .devcontainer.json --- .devcontainer/devcontainer.json | 9 ++++++- .vscode/launch.json | 48 +++++++++++++++++++++++++++++++++ 3rdparty/make_php.mk | 18 ++++++++++++- 3 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 4b101bf..9afb686 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -11,7 +11,14 @@ // "extensionsExtra": "xdebug redis" // } }, - + "customizations": { + "vscode": { + "extensions": [ + "ms-python.python", + "xdebug.php-debug" + ] + } + }, // Use 'forwardPorts' to make a list of ports inside the container available locally. // This can be used to network with other containers or the host. // "forwardPorts": [5000, 5432], diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..9dc6b4d --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,48 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Listen for Xdebug", + "type": "php", + "request": "launch", + "port": 9003 + }, + { + "name": "Launch currently open script", + "type": "php", + "request": "launch", + "program": "${file}", + "cwd": "${fileDirname}", + "port": 0, + "runtimeArgs": [ + "-dxdebug.start_with_request=yes" + ], + "env": { + "XDEBUG_MODE": "debug,develop", + "XDEBUG_CONFIG": "client_port=${port}" + } + }, + { + "name": "Launch Built-in web server", + "type": "php", + "request": "launch", + "runtimeArgs": [ + "-dxdebug.mode=debug", + "-dxdebug.start_with_request=yes", + "-S", + "localhost:0" + ], + "program": "", + "cwd": "${workspaceRoot}", + "port": 9003, + "serverReadyAction": { + "pattern": "Development Server \\(http://localhost:([0-9]+)\\) started", + "uriFormat": "http://localhost:%s", + "action": "openExternally" + } + } + ] +} \ No newline at end of file diff --git a/3rdparty/make_php.mk b/3rdparty/make_php.mk index e07a660..80f5b97 100644 --- a/3rdparty/make_php.mk +++ b/3rdparty/make_php.mk @@ -7,7 +7,7 @@ LIBVER_php := 7.4.6 php_download: download/php-${LIBVER_php}.tar.gz .PHONY: php_build -php_build: php/bin/php-cgi +php_build: php/bin/php-cgi php/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so .PHONY: php_clean php_clean: @@ -31,3 +31,19 @@ php/bin/php-cgi: download/php-${LIBVER_php}.tar.gz | postgresql_build $(MAKE) -C php_build/php-$(LIBVER_php) $(MAKE) -C php_build/php-$(LIBVER_php) install $(RM) -r php_build + +# Change xdebug version if updating php version (https://xdebug.org/wizard) +download/xdebug-3.1.6.tgz: + mkdir -p download/ + cd download && wget https://xdebug.org/files/xdebug-3.1.6.tgz + +php/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so: php/bin/php-cgi download/xdebug-3.1.6.tgz + mkdir -p $(BASEDIR)/php_xdebug_build \ + && cd $(BASEDIR)/php_xdebug_build \ + && tar xf $(BASEDIR)/download/xdebug-3.1.6.tgz \ + && cd $(BASEDIR)/php_xdebug_build/xdebug-3.1.6 \ + && $(BASEDIR)/php/bin/phpize \ + && ./configure --with-php-config=$(BASEDIR)/php/bin/php-config + $(MAKE) -C $(BASEDIR)/php_xdebug_build/xdebug-3.1.6 + cp $(BASEDIR)/php_xdebug_build/xdebug-3.1.6/modules/xdebug.so $(BASEDIR)/php/lib/php/extensions/no-debug-non-zts-20190902/ + $(RM) -r $(BASEDIR)/php_xdebug_build \ No newline at end of file