One possible solution is to make sure that the files and directories in the project directory are owned by the same user that is running the Docker containers. This can be done by running the following command in the terminal:
sudo chown -R $USER:$USER /path/to/project
Replace /path/to/project with the actual path to your project directory.
Another possible solution is to configure PHPStorm to use the Docker container as the remote interpreter. To do this, follow these steps:
- Open the project in PHPStorm.
- Go to
File > Settings > Languages & Frameworks > PHP. - Click on the
...button next to theCLI Interpreterfield. - Click on the
+button to add a new interpreter. - Select
From Docker, Vagrant, VM, Remote...from the list. - Select
Docker Composefrom the dropdown menu. - Select the
docker-compose.ymlfile for your project. - Select the service that you want to use as the interpreter (e.g.
php). - Click on
OKto save the interpreter settings. - Go to
File > Settings > Languages & Frameworks > PHP > PHPUnit. - Select the
Use custom autoloaderoption. - Enter the path to the
autoload.phpfile in your project directory (e.g./var/www/html/vendor/autoload.php). - Click on
OKto save the PHPUnit settings.
After configuring PHPStorm to use the Docker container as the remote interpreter, you should be able to edit files in your project directory using PHPStorm.