There are three configurations this post covers
Local Development
Use the default if working locally
If you are using CakePHP 4 and developing on the local file system (straight from Windows) use this:
1 | Debugger::setEditor( 'vscode' ); |
If your project is in C:\Users\ja.TGNT\cake_test you get a URL as follows on a Windows 11 System
1 | vscode://file/C:\Users\ja.TGNT\cake_test\vendor\cakephp\cakephp\src\Controller\Controller.php:547 |
For WSL
To get to a file hosted in WSL you have to make sure the link targets the full path to the file in the WSL environment.
In this case I have the source code being served from a folder in WSL via a Docker container.
So I have to remove the CakePHP 4 ROOT (/var/www/wms) and prepend the WSL path to that mounted folder.
1 2 3 4 5 6 7 8 9 | Debugger::addEditor( 'wsl' , function ( $file , $line ) { $file = str_replace (ROOT, '' , $file ); $prefix = '/home/ja/dev/wms' ; return "vscode://vscode-remote/wsl+Ubuntu-22.04{$prefix}{$file}:{$line}" ; }); Debugger::setEditor( 'wsl' ); |
An example of a URL for WSL
1 | vscode://vscode-remote/wsl+Ubuntu-22.04/home/ja/dev/wms/vendor/cakephp/cakephp/src/Database/Expression/QueryExpression.php:647 |
Note the /wsl+Ubuntu-22.04
which is the Windows Subsystem for Linux Distribution being used
Windows 11 Host and Docker using WSL2 Engine
This will allow you to attach to a running docker Development container
1 2 3 4 5 6 7 8 9 10 11 12 13 | Debugger::addEditor( 'docker' , function ( $file , $line ) { $container = [ 'containerName' => 'wms-php-1' ]; $json = json_encode( $container ); $hex = bin2hex( $json ); return "vscode://vscode-remote/attached-container+{$hex}{$file}:{$line}" ; }); Debugger::setEditor( 'docker' ); |
An example of a URL for attaching to a running Docker container
1 | vscode://vscode-remote/attached-container+7b22636f6e7461696e65724e616d65223a22776d732d7068702d31227d/var/www/wms/vendor/cakephp/cakephp/src/Database/Expression/QueryExpression.php:647 |
References
https://github.com/microsoft/vscode-remote-release/issues/6832
0 Comments