DEVSENSE / phptools-docs

PHP Tools public content
Apache License 2.0
79 stars 10 forks source link

pathMappings configuration in launch.json not working #528

Open set0x opened 6 months ago

set0x commented 6 months ago

Hi, the pathMappings configuration in launch.json not working in visual code.

When the test finished as failure it doesn't show output error and open the file with remote path.

Here is a video to show error:

This is my launch.json configuration

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "xdebug",
      "type": "php",
      "request": "launch",
      "port": 9003,
      "exclude": ["**/vendor/**/*.php"],
      "pathMappings": {
        "/var/www/html": "${workspaceRoot}"
      }
    }
  ]
}

and this is my settings

{
  "php.codeLens.enabled": false,
  "php.problems.scope": "all",
  "phpunit.command": "./vendor/bin/sail art test ${phpunitargs}"
}

If the test was successful, the extension works perfectly.

Miloslav commented 6 months ago

Hi,

Thank you for creating the issue.

pathMapping is currently not used in the context of tests, only when debugging. But it's something we can take a look at.

May I ask you more about your setup? What is your local OS? I assume you are using docker containers, but you are not using Remote extension. So you want to develop locally but run/debug/test inside the container.

Thank you for any additional info

set0x commented 6 months ago

Hi, here is my setup:

My setup is Visual Studio Code in "WSL: Ubuntu" mode, and I would like to be able to use my "local" (WSL) configuration for development and to run both tests and debug mode on my Docker container (currently using Laravel's "sail" in multiple projects). This allows me to avoid duplicating my Visual Studio Code configurations for each remote container.

I hope I have explained myself well, I don't speak English very well.

Thanks

Miloslav commented 6 months ago

Thank you so much for additional information.

Now, we do not match the launch profile with the testing. What we will do is find a way how to pair the profile and therefore use the pathMapping. That should do it.

I'll keep you posted.

tyler36 commented 3 months ago

I came across this issue when checking if I can get path mapping for PHPunit tests.

I use the following setting which works well when tests pass:

    "phpunit.command": "ddev exec phpunit --teamcity",

When tests fail, it tries to open the file using the path from inside the container.

While reusing the value from launch.json is great, I think a seperate setting might be easier for new developer and debugging.