Closed tg-jbenson closed 8 months ago
Hey @tg-jbenson,
If you remove the dockerExecutablePathCBF and dockerExecutablePathCS path properties does anything change?
Everything looks good to me though, I can't replicate this with the same configuration on Linux.
If that doesn't work, could you send over any logs from the Output terminal in VS Code? See screenshot of where to find this.
Cheers
Hey, thank you for taking a look! That did change something, with these settings:
{
"phpsab.docker.dockerEnabled": true,
"phpsab.docker.dockerContainer": "wordpress",
"phpsab.docker.dockerWorkspaceRoot": "/var/www/html/wp-content/plugins/my-plugin",
"phpsab.docker.snifferMode": "onType",
"phpsab.docker.debug": true,
}
Now if I run the PHPCBF: Fix this file with F1 it pops up a VScode message:
Fixer is disable for this workspace or PHPCBF was not found for this workspace.
but I'm not getting anything from Output, or in the devtools console with debug enabled
I'm not sure if it matters, but I only have phpcs/phpcbf and composer/php installed in the container, not locally at all
Ah sorry, I missed the output dropdown, thanks for the screenshot here is my log
["INFO" - 1:00:01 PM] DOCKER: Resolved docker path:
["INFO" - 1:00:01 PM] DOCKER: Resolved docker path:
["INFO" - 1:00:01 PM] The phpcs executable was not found for my-plugin
["INFO" - 1:00:01 PM] The phpcbf executable was not found for my-plugin
["INFO" - 1:00:01 PM] CONFIGURATION
{
"resources": [
{
"useFilepath": false,
"containerExec": "docker",
"fixerEnable": false,
"fixerArguments": [],
"workspaceRoot": "/home/bensonism/projects/my-plugin",
"executablePathCBF": "",
"executablePathCS": "",
"composerJsonPath": "composer.json",
"standard": null,
"autoRulesetSearch": true,
"allowedAutoRulesets": [
".phpcs.xml",
".phpcs.xml.dist",
"phpcs.xml",
"phpcs.xml.dist",
"phpcs.ruleset.xml",
"ruleset.xml"
],
"snifferEnable": false,
"snifferArguments": [],
"dockerEnabled": true,
"dockerContainer": "wordpress",
"dockerWorkspaceRoot": "/var/www/html/wp-content/plugins/my-plugin",
"dockerExecutablePathCBF": "",
"dockerExecutablePathCS": ""
}
],
"snifferMode": "onType",
"snifferShowSources": false,
"snifferTypeDelay": 250,
"debug": true
}
OKAY, I made some progress, maybe my project is setup weird, but my composer.json isnt in the project root, its one folder down in project-root/my-plugin/composer.json -- because that's the folder that gets mounted in the container and where I want it to run composer install etc.
SO by adding the ``"phpsab.docker.composerJsonPath": "my-plugin/composer.json",``` setting
Now it's resolved the paths and it's able to fix my files when I run the command with F1 + PHPCBF: Fix this file, but it's not giving me any of the sniff highlighting that the original extension was doing, and I'm not getting any errors related to that in the output logs either
In case its helpful here's the logs when I add the setting:
["INFO" - 1:18:38 PM] DOCKER: Resolved docker path: /var/www/html/wp-content/plugins/my-plugin/vendor/bin/phpcbf
["INFO" - 1:18:38 PM] DOCKER: Resolved docker path: /var/www/html/wp-content/plugins/my-plugin/vendor/bin/phpcs
["INFO" - 1:18:38 PM] CONFIGURATION
{
"resources": [
{
"useFilepath": false,
"containerExec": "docker",
"fixerEnable": true,
"fixerArguments": [],
"workspaceRoot": "/home/bensonism/projects/my-plugin",
"executablePathCBF": "/home/bensonism/projects/my-plugin/my-plugin/vendor/bin/phpcbf",
"executablePathCS": "/home/bensonism/projects/my-plugin/my-plugin/vendor/bin/phpcs",
"composerJsonPath": "my-plugin/composer.json",
"standard": null,
"autoRulesetSearch": true,
"allowedAutoRulesets": [
".phpcs.xml",
".phpcs.xml.dist",
"phpcs.xml",
"phpcs.xml.dist",
"phpcs.ruleset.xml",
"ruleset.xml"
],
"snifferEnable": true,
"snifferArguments": [],
"dockerEnabled": true,
"dockerContainer": "wordpress",
"dockerWorkspaceRoot": "/var/www/html/wp-content/plugins",
"dockerExecutablePathCBF": "/var/www/html/wp-content/plugins/my-plugin/vendor/bin/phpcbf",
"dockerExecutablePathCS": "/var/www/html/wp-content/plugins/my-plugin/vendor/bin/phpcs"
}
],
"snifferMode": "onType",
"snifferShowSources": false,
"snifferTypeDelay": 250,
"debug": true
}
and when I run the fixer:
["INFO" - 1:21:05 PM] Fixer running
["INFO" - 1:21:05 PM] Standards Search paths:
[
"/home/bensonism/projects/my-plugin/my-plugin/",
"/home/bensonism/projects/my-plugin/"
]
["INFO" - 1:21:05 PM] Standards Search files:
[
"/home/bensonism/projects/my-plugin/my-plugin/.phpcs.xml",
"/home/bensonism/projects/my-plugin/my-plugin/.phpcs.xml.dist",
"/home/bensonism/projects/my-plugin/my-plugin/phpcs.xml",
"/home/bensonism/projects/my-plugin/my-plugin/phpcs.xml.dist",
"/home/bensonism/projects/my-plugin/my-plugin/phpcs.ruleset.xml",
"/home/bensonism/projects/my-plugin/my-plugin/ruleset.xml",
"/home/bensonism/projects/my-plugin/.phpcs.xml",
"/home/bensonism/projects/my-plugin/.phpcs.xml.dist",
"/home/bensonism/projects/my-plugin/phpcs.xml",
"/home/bensonism/projects/my-plugin/phpcs.xml.dist",
"/home/bensonism/projects/my-plugin/phpcs.ruleset.xml",
"/home/bensonism/projects/my-plugin/ruleset.xml"
]
["INFO" - 1:21:05 PM] Standards Search found:
"/home/bensonism/projects/my-plugin/my-plugin/phpcs.xml"
["INFO" - 1:21:05 PM] DOCKER: Resolved docker path: /var/www/html/wp-content/plugins/my-plugin/phpcs.xml
["INFO" - 1:21:05 PM] DOCKER: Resolved docker path: /var/www/html/wp-content/plugins/my-plugin/my-plugin.php
["INFO" - 1:21:05 PM] FIXER COMMAND: docker exec -i wordpress /var/www/html/wp-content/plugins/my-plugin/vendor/bin/phpcbf -q --standard=/var/www/html/wp-content/plugins/my-plugin/phpcs.xml --stdin-path=/var/www/html/wp-content/plugins/my-plugin/my-plugin.php -
["INFO" - 1:21:06 PM] Fixer ran for 0.256 seconds
Hey @tg-jbenson,
Thanks for the info!
I've done some tests locally and put together a new release which will hopefully patch this.
The release version is 0.0.9. Can you test it out and see if it works for you?
This is the config I was working with (which hopefully is close to yours!):
{
"phpsab.docker.dockerEnabled": true,
"phpsab.docker.dockerContainer": "<container_id>",
"phpsab.docker.dockerWorkspaceRoot": "/var/www/html",
"phpsab.docker.composerJsonPath": "my-plugin/composer.json",
"phpsab.docker.dockerExecutablePathCBF": "/var/www/html/my-plugin/vendor/bin/phpcbf",
"phpsab.docker.dockerExecutablePathCS": "/var/www/html/my-plugin/vendor/bin/phpcs",
"phpsab.docker.debug": true,
"phpsab.docker.snifferMode": "onType",
}
This results in a configuration object in Output like this:
{
"resources": [
{
"useFilepath": false,
"containerExec": "docker",
"fixerEnable": true,
"fixerArguments": [],
"workspaceRoot": "/home/matthew/Workspace/phpcs-test",
"executablePathCBF": "",
"executablePathCS": "",
"composerJsonPath": "my-plugin/composer.json",
"standard": null,
"autoRulesetSearch": true,
"allowedAutoRulesets": [
".phpcs.xml",
".phpcs.xml.dist",
"phpcs.xml",
"phpcs.xml.dist",
"phpcs.ruleset.xml",
"ruleset.xml"
],
"snifferEnable": true,
"snifferArguments": [],
"dockerEnabled": true,
"dockerContainer": "d27cc988ee07",
"dockerWorkspaceRoot": "/var/www/html",
"dockerExecutablePathCBF": "/var/www/html/my-plugin/vendor/bin/phpcbf",
"dockerExecutablePathCS": "/var/www/html/my-plugin/vendor/bin/phpcs"
}
Cheers
Its working!
Everything is working great now! Thank you so much for the quick fix, this is the best! Before I was using a hacky technique to pass the executable through a shell script to the container, but this is much better.
Hey @tg-jbenson,
Glad to hear it! This - slightly hacky in itself - extension only exists as an alternative to the shell script piping approach.
I'll close off this issue now.
Cheers
Hello, I'm really excited to use this extension, but I cannot get it to work. Do I need to have the original plugin installed in order to use the docker version?
These are my settings:
I've verified that I can run
docker exec -i wordpress /var/www/html/wp-content/plugins/my-plugin/vendor/bin/phpcs -i
and it displays the list of installed standards correctly.Even with the debug enabled I'm not getting any error messages or feedback from the developer tools console, nor any errors in VS Code.
I'm developing on WSL2 ubuntu 20.04 distro with Docker Desktop using a docker-compose.yml file to setup my containers.
Any help greatly appreciated 🙏