Linux permissions and Document Root

I have managed to get yii installed and running the demonstration basic project.

When I run gii to try to create a model there are errors in writing the files due to permissions.

As per the instructions I execute composer and store the basic website files under the DocumentRoot so the yii files are inside /var/www/html/basic. But I have to do that using "sudo" because I am a user and the DocumentRoot belongs to root. As a consequence (I think), even the yii framework when run in the browser cannot change any of the files.

What is the correct thing to do? I am very unexperienced in Linux, so this is probably a very basic issue that I misinderstand. Do I need to make myself a member of the root group? Do I chown all of the basic directory to be owned by me? Do I just login as root and do everything as the root user?

How do I organise my work pattern so that the yii framework is stored in the DocumentRoot, which is owned by root, but also be able to change the file contents without always using "sudo"?

I think that this might be a common problem faced by new users of Linux, so apologies if this is not really a yii thing.

In frustration I just did this:

chmod ugo+rwx -R basic

Now it works but I doubt this is the correct thing to do.

What is the correct way to do this?