Skip to content
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

Open
yungts97 opened this issue Dec 1, 2023 · 2 comments
Open

Run Laravel Pint inside docker container #49

yungts97 opened this issue Dec 1, 2023 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@yungts97
Copy link

yungts97 commented Dec 1, 2023

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?

@d8vjork
Copy link
Member

d8vjork commented Dec 26, 2023

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

@d8vjork d8vjork added the enhancement New feature or request label Dec 26, 2023
@d8vjork d8vjork added the help wanted Extra attention is needed label Mar 13, 2024
@yusufkandemir
Copy link

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:

  • docker exec some-container
  • docker compose exec some-container-within-compose
  • spin run php
  • relevant Sail command
  • any CLI wrapping Docker (like Sail or Spin)
  • etc.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants