Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vertoo's avatar

Laravel Pint in PhpStorm + Docker on WSL2

hello, I have problems with Laravel Pint configuration in PhpStorm. I run projects with docker-compose, OS is Windows 11 but project files are under WSL2.

In actions on save I have disabled formatting PHP code. File watcher configuration: Program: docker-compose

Arguments: exec -u 1000 -it app /app/vendor/bin/pint /$/FileRelativePath$

Output paths to refresh: /app/$/FileRelativePath$ also tested another variants

Working directory: $UnixSeparators($ProjectFileDir$\app)$ checked others too

And never have I seen this working correctly.

About my project configuration:

  • wsl2
  • docker-compose
  • in container project in directory /app

PhpStorm works fine with my docker-compose, probably is a problem with arguments or output path.

0 likes
4 replies
vertoo's avatar
vertoo
OP
Best Answer
Level 6

Found a solution, just add -T

Program: docker-compose

Arguments: exec -T app /app/vendor/bin/pint /$/FileRelativePath$

Working directory and output paths: empty

Second variant:

Program: wsl.exe

Arguments: docker-compose exec -T app /app/vendor/bin/pint /$/FileRelativePath$

2 likes
mafavreau's avatar

Hey everyone, if you're like me, you stumbled on this post while trying to make Pint work in WSL in PhPStorm as a file watcher and not in the Quality Tools. I gotta say that this post is by far the one that was closest to the solution I needed. I don't know if something has changed, but this solution wasn't working for. After 2 days of trying multiple thing, I managed to fix my error by using the $UnixSeparators$ macro to turn the '' in the RelativePath into a '/'. Now this looks kind of obvious, but yesterday while I was pulling my hair out, it wasn't...

So, if anyone needs a clue, here's the argument for the docker-compose. Know that I'm using Sail, that's why the docker is laravel.test.

Take care!

exec -T laravel.test /var/www/html/vendor/bin/pint $UnixSeparators($FileRelativePath$)$
1 like
Fernandafmsf's avatar

Hello! What was the error you were getting? And where were you putting the $UnixSeparators code? I am also not able to run pint as a file watcher on my phpstorm, using very much the same configuration as you. The error I'm getting is something like: ""DOCKER_GID" variable is not set. Defaulting to a blank string.""

This happens for many docker variables, and they seem to be ok. I've tried you solution and the one above but had no different results

lucastb's avatar

I'm running Laravel inside Docker inside WSL using sail.

I managed to run pint using:

Program: wsl.exe

Arguments:

-d ubuntu -e /bin/bash -c "cd /home/lucas/mytest && ./vendor/bin/sail pint"

But, I can't make it so the path is relative to my project. The $ProjectFileDir$ gives me \\wsl.localhost\Ubuntu\home\lucas\mytest. I know I can use $UnixSeparators($ProjectFileDir$)$ but does anyone know if it's possible get the homepath without \\wsl.localhost\Ubuntu\?

Please or to participate in this conversation.