How to edit PHP code which is under webroot (needs root access...)

I’m trying to write a database query in PHP, the database being served by XAMPP.
XAMPP’s webroot is located in /opt/lampp/htdocs on my Linux system (Manjaro), which is the root part of the file system. Hence, any applications that wants to write any files here need root access.
Before I go and try to start my IDE (PHPStorm) as root, I suspect that’s a very unusual way of doing things, and there’s probably a more simple and proper solution.
If I want to place my php files outside of the XAMPP webroot for editing, that means XAMPP won’t be able to run them, and I can’t write code without running it a lot to see happens.
Surely there’s some standard solution for this that I haven’t found on the interwebs?

Finally thought of the right search terms:
We can grant read/write permissions to a regular user for only the webroot folder in Linux like so:

sudo chown -R ben:ben /opt/lampp/htdocs

where ben is my linux user and ben is its primary group name
this allows the user that I run my IDE as to modify any file under this directory.
As far as I know, this shouldn’t be done on a live server, but XAMPP is only for development and testing purposes and not meant for serving live sites anyway, so it should be fine, I guess?