-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Run Laravel Pint inside docker container #49
Comments
This will be difficult as is already a challenge having a Laravel Sail setup (see #34) Only difficult part here is determining in which container the code and PHP with the dependencies is |
https://github.com/m1guelpf/better-pest handles this through configuration. {
"better-pest.docker.enable": true,
"better-pest.docker.command": "command to run",
"better-pest.docker.paths": {
"${workspaceFolder}": "/var/www/html",
"/some/other/path": "/whatever"
},
} The command can be:
The paths get used to transform paths from the host to the Docker container. With the assumption of the Docker container having configured a working directory and having 1-to-1 mapping with the host files, this config can be avoided. But, to cover all cases, it's better to have that configuration. So, the final command becomes something like this: $ docker exec some-container vendor/bin/pest
# or, for specific files:
$ docker exec some-container vendor/bin/pest tests/Unit/ExampleTest.php This solution also eliminates the need for having special Laravel Sail logic. |
I have an old trick up my sleeve I take out whenever an extension does not support docker stuff, I use this in the past for phpcs and phpcbf without any issue, and seem to be working for this extension too.
{
"laravel-pint.runInLaravelSail": false,
"laravel-pint.fallbackToGlobalBin": false,
"laravel-pint.executablePath": ".vscode/pint"
}
#!/bin/bash
LOCAL_PATH=`pwd`
REMOTE_PATH='/var/www/html'
for param; do
if [[ "$param" == *"$LOCAL_PATH"* ]]; then
param=${param//$LOCAL_PATH/$REMOTE_PATH}
fi
newparams+=("$param")
done
/usr/bin/docker compose -f $LOCAL_PATH/docker-compose.yml exec php /var/www/vendor/bin/pint ${newparams[@]} To sum it up, it runs docker compose and runs the pint command inside the container, in the eventuality all params are rewritten to map the local directory to the container's one. |
I'm using WSL2 and not PHP installed in my WSL2. And I run my Laravel project with a custom PHP docker container. I'm not using Laravel Sail for that. Is there any way to make Laravel Pint run it on my PHP docker container?
The text was updated successfully, but these errors were encountered: