Skip to content

Commit

Permalink
properly setup debugger for everyone and contribution guide
Browse files Browse the repository at this point in the history
  • Loading branch information
lohanidamodar committed Jul 11, 2021
1 parent 5073c26 commit 74b24df
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
.DS_Store
.php_cs.cache
debug/
app/sdks
app/sdks
dev/yasd_init.php
24 changes: 24 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,30 @@ docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7

The Runtimes for all supported cloud functions (multicore builds) can be found at the [appwrite/php-runtimes](https://github.com/appwrite/php-runtimes) repository.

## Debug

Appwrite uses [yasd](https://github.com/swoole/yasd) debugger, which is available by default in debug build of Appwrite. You can connect to the debugger using VS Code [PHP Debug](https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug) extension or if you are in PHP Storm you don't need any plugin. Below are the settings required for remote debugger connection.

Finally you need to create an init file. Duplicate **dev/yasd_init.php.stub** file and name it **dev/yasd_init.php** and there change the IP address to your development machine's IP. Without the proper IP address debugger wont connect.

### VS Code Launch Configuration

```json
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9005,
"pathMappings": {
"/usr/src/code": "${workspaceRoot}"
},
}
```

### PHPStorm Setup

In settings, go to **Languages & Frameworks** > **PHP** > **Debug**, there under **Xdebug** set the debug port to **9005** and enable **can accept external connections** checkbox.

## Tests

To run all tests manually, use the Appwrite Docker CLI from your terminal:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ RUN echo extension=redis.so >> /usr/local/etc/php/conf.d/redis.ini
RUN echo extension=imagick.so >> /usr/local/etc/php/conf.d/imagick.ini
RUN echo extension=yaml.so >> /usr/local/etc/php/conf.d/yaml.ini
RUN echo extension=maxminddb.so >> /usr/local/etc/php/conf.d/maxminddb.ini
RUN if [ "$TESTING" == "true" ]; then printf 'zend_extension=yasd \nyasd.debug_mode=remote \nyasd.remote_host=192.168.1.64 \nyasd.remote_port=9005 \nyasd.log_level=0 \nyasd.breakpoints_file="yasd.log"' >> /usr/local/etc/php/conf.d/yasd.ini; fi
RUN if [ "$TESTING" == "true" ]; then printf "zend_extension=yasd \nyasd.debug_mode=remote \nyasd.init_file=/usr/local/dev/yasd_init.php \nyasd.remote_port=9005 \nyasd.log_level=-1" >> /usr/local/etc/php/conf.d/yasd.ini; fi

RUN if [ "$TESTING" == "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
Expand Down
4 changes: 4 additions & 0 deletions dev/yasd_init.php.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

echo 'execute init_file success' . PHP_EOL;
Yasd\Api\setRemoteHost('127.0.0.1'); //Set your development machine's IP
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ services:
- ./public:/usr/src/code/public
- ./src:/usr/src/code/src
- ./debug:/tmp
- ./dev:/usr/local/dev
depends_on:
- mariadb
- redis
Expand All @@ -77,8 +78,6 @@ services:
- -e
- app/http.php
- -dopcache.preload=opcache.preload=/usr/src/code/app/preload.php


environment:
- _APP_ENV
- _APP_LOCALE
Expand Down

0 comments on commit 74b24df

Please sign in to comment.