NextCloud debugging help

Hi All

I am intrigued about NextCloud the possibility that I can control my own data is really good. That’s why I am interested in how I could develop apps to it.

I would like to know what kind of setups you have on developing. If you are running on Docker etc. And how you can debug your controller code with VS Code. Is there a way to run my app so that I could add breakpoints etc. to my PHP-controllers and see what is happening when I run this on the development Nextcloud instance?

Thank you

Best Regards Tuomas

I am using VS Code together with Julius Haertel’s setup (which is docker-based).

And yes, step debugging is possible with a local dev instance of the NC server. You will need to setup some path mappings. As maintainer of the cookbook app, I am just linking that code here for reference.

If you run into issues, just ping me. If you need more information or have further questions, feel free to ask!



So you are running the NC locally without Docker? :slight_smile:
Thank you for the launch.json example :blush:

The linked setup by Julius Haertl is in fact an enhanced docker compose file. So, I am running the NC within docker.

I am still having trouble attaching the debugger to the VSCode. I downloaded the setup by Julius Haertl and got the env running. I have even tried that I can access my host from the docker container.

But when I start the debugger in the VSCode, nothing happens even when I should hit a breakpoint. I ran the “./scripts/php-mod-config nextcloud xdebug.mode debug” command. But still I cannot get any connection to my VSCode. I also tried PhpStorm but the issue is the same.

I someone could help a Php - noob, I would greatly appreciate it.

Thank you

I got it working…

I needed to tweak the docker-compose - file. I added these to the nextcloud section, under the environment:

  XDEBUG_MODE: develop, debug

If you want to run it under vs code, report back. I might be able to help there as well, but that might require a few tests.

1 Like

@stuma I am sorry, but your like is a bit unclear to me. Do you want to express your thank for the offer to help with VS code or confirm the need to/wish to use it? In the first case, I would be done with the topic in the latter, I would write and try to help at best.

You would need to set xdebug.log_level to 7 or similar using the command scripts/php-mod-config nextcloud xdebug.log_level 7. In a similar manner you can reset to 1 after having done the debugging of the connection.
Open the docker logs with docker compose logs -f --tail 1 nextcloud. Keep an eye on the output while you try with VS code to open a debugging session. There you can see

  • if a debugging session was requested
  • if the VS code is accepting requests by PHP for a debugging session
  • the path mappings and check manually if they match up with the actual paths

That should get you running.

1 Like

Thank you for the update. I just was so excited that I got the PhpStorm working, so I did not want to rock the boat yet. I will try this in VSCode also so this is really great. :slight_smile:

Thank you so much

1 Like