From 77caf64076c6f56bc18bd173a538cd6775cd2000 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Mon, 6 Nov 2023 10:08:11 +0000 Subject: [PATCH] Add XDebug to Appwrite --- CONTRIBUTING.md | 8 ++++---- Dockerfile | 4 ++-- dev/xdebug.ini | 6 ++++++ dev/yasd_init.php.stub | 4 ---- 4 files changed, 12 insertions(+), 10 deletions(-) create mode 100644 dev/xdebug.ini delete mode 100644 dev/yasd_init.php.stub diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ccd61e742..7aa97050d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -345,13 +345,13 @@ Things to remember when releasing SDKs: ## Debug -Appwrite uses [yasd](https://github.com/swoole/yasd) debugger, which can be made available during build of Appwrite. You can connect to the debugger using VS Code's [PHP Debug](https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug) extension. +Appwrite uses [XDebug](https://github.com/xdebug/xdebug) debugger, which can be made available during build of Appwrite. You can connect to the debugger using VS Code's [PHP Debug](https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug) extension. If you are in PHP Storm you don't need any plugin. Below are the settings required for remote debugger connection: -1. Create an init file. -2. Duplicate **dev/yasd_init.php.stub** file and name it **dev/yasd_init.php**. -3. Set **DEBUG** build arg in **appwrite** service in **docker-compose.yml** file. +1. Set **DEBUG** build arg in **appwrite** service in **docker-compose.yml** file. +2. If needed edit the **dev/xdebug.ini** file to your needs. +3. Launch your Appwrite instance while your debugger is listening for connections. ### VS Code Launch Configuration diff --git a/Dockerfile b/Dockerfile index 849be37ea..7826c8621 100755 --- a/Dockerfile +++ b/Dockerfile @@ -56,6 +56,7 @@ COPY ./public /usr/src/code/public COPY ./bin /usr/local/bin COPY ./docs /usr/src/code/docs COPY ./src /usr/src/code/src +COPY ./dev /usr/src/code/dev # Set Volumes RUN mkdir -p /storage/uploads && \ @@ -110,8 +111,7 @@ RUN chmod +x /usr/local/bin/hamster && \ RUN mkdir -p /etc/letsencrypt/live/ && chmod -Rf 755 /etc/letsencrypt/live/ # Enable Extensions -RUN if [ "$DEBUG" == "true" ]; then printf "zend_extension=yasd \nyasd.debug_mode=remote \nyasd.init_file=/usr/src/code/dev/yasd_init.php \nyasd.remote_port=9005 \nyasd.log_level=-1" >> /usr/local/etc/php/conf.d/yasd.ini; fi - +RUN if [ "$DEBUG" == "true" ]; then cp /usr/src/code/dev/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini; fi RUN if [ "$DEBUG" == "true" ]; then echo "opcache.enable=0" >> /usr/local/etc/php/conf.d/appwrite.ini; fi RUN echo "opcache.preload_user=www-data" >> /usr/local/etc/php/conf.d/appwrite.ini RUN echo "opcache.preload=/usr/src/code/app/preload.php" >> /usr/local/etc/php/conf.d/appwrite.ini diff --git a/dev/xdebug.ini b/dev/xdebug.ini new file mode 100644 index 000000000..e29c8bd46 --- /dev/null +++ b/dev/xdebug.ini @@ -0,0 +1,6 @@ +zend_extension=xdebug + +[xdebug] +xdebug.mode=develop,debug +xdebug.client_host=host.docker.internal +xdebug.start_with_request=yes \ No newline at end of file diff --git a/dev/yasd_init.php.stub b/dev/yasd_init.php.stub deleted file mode 100644 index efcc37c0b..000000000 --- a/dev/yasd_init.php.stub +++ /dev/null @@ -1,4 +0,0 @@ -