Debug CLI Laravel commands for multiple projects on same Docker container

Hi there. I'm looking for some guidance on working with multiple Laravel projects. My current dev enviroment is composed of:

- PHPStorm 2022.3.3 on Windows 10

- Docker Desktop on WSL2

- Docker-compose with a PHP FPM 7.1 instance which has 2 Laravel Web Projects and 1 Library

I need to debug some Artisan Commands that are executed on WSL2 terminal after getting into the container. The problem is that the only way to do that is to set "PHP_IDE_CONFIG" env variable, which in my case should be different depending on which project I'm currently working, due to the fact that there is one server per project. Is there a way to avoid changing the var value each time a switch projects? I know that the most efficient way would be to have separate instances for both web projects but I should talk to the DevOps team first. Another alternative that I think of (but really far from a neat solution) is to make use of "ondir" process to change the variable each I navigate to a different project path.

I would like to know if there is an alternative to this.

I hope I made myself clear. Let me know for further details.

Thank you.


1 comment

First thing that comes to mind is that you could have the same serverName for all those projects, and thus the project that gets the connection would be the one that has listening for incoming connections enabled.

Then, you can use something like direnv to set different environment variables depending on the project directory.


Please sign in to leave a comment.