清理Vscode的缓存
C:\Users\Administrator\AppData\Roaming\Code
删除 Cache 和 CachedData
应用的扩展
Remote SSH
phpcs - php psr12规范
PHP DocBlocker - phpDoc注释
PHP Debug - php xdebug 调试
PHP Intelephense - php语法检查
PHP Namespace Resolver - php命名空间引用
vscode 全局 setting 配置
{"php.validate.executablePath": "/usr/bin/php","workbench.colorTheme": "Default Light+","editor.fontSize": 17,"intelephense.environment.includePaths": ["/home/wwwroot/xmvc/composer/vendor",],"php.debug.ideKey" : "vsc", "php.debug.executablePath": "/usr/bin/php","workbench.tree.indent": 24,"editor.formatOnPaste": true,"workbench.startupEditor": "none","[php]": {"editor.defaultFormatter": "bmewburn.vscode-intelephense-client"},"intelephense.telemetry.enabled": false,"phpcs.enable": true,"phpcs.executablePath": "/home/qg/.config/composer/vendor/bin/phpcs","phpcs.standard": "PSR12","phpcs.ignorePatterns": ["*/vendor/*","*/cache/*","*/view/*","*/xview/*"]
}
[Remote SSH]
安装 vscode 的 Remote SSH 扩展
Ctrl+Shift+P 打开命令面板输入 Remote-SSH: Connect to Host...,
然后选择 Configure SSH Hosts...。在配置文件中添加SSH 主机的信息
配置文件一般在 C:\Users\Administrator\.ssh 目录下
Host VM.debian12HostName vm.debian12User rootPort 22#PreferredAuthentications passwordIdentityFile C:\Users\Administrator\.ssh\id_rsa#HostName
#vm.debian12 在 hosts 指向了 debian虚拟机的IP 192.168.1.90
#PreferredAuthentications password 使用密码认证,每次打开vscode需要输入一次
#IdentityFile your_path_file 使用密钥进行身份验证
在 windows 电脑上生成 SSH 密钥
> ssh-keygen -t rsa -b 4096 -C "admin.yipxxxx.com"
> Enter++
C:\Users\Administrator\.ssh 目录下会生成 id_rsa(私钥) 和 id_rsa.pub(公钥) 两个文件
在 debian 电脑上添加公钥
> mkdir ~/.ssh
> touch ~/.ssh/authorized_keys
> chmod 700 ~/.ssh
> chmod 600 ~/.ssh/authorized_keys
将 windows下生成的 SSH 公钥文件 id_rsa.pub 中的内容复制到 ~/.ssh/authorized_keys 文件中
[composer]
将 composer.phar 改名为 composer 放入 /usr/local/bin 全局可执行目录下, 并使用普通用户来操作 composer
查看全局安装路径
composer global config home
添加 comoser bin 到环境目录
export PATH="$HOME/.config/composer/vendor/bin:$PATH"
source ~/.bashrc #使用path生效
[phpcs]
全局安装
composer global require "squizlabs/php_codesniffer=*"
phpcs --version
phpcs 在 .vscode 的当前工作目录的 setting.josn 中加入配置
"phpcs.enable": true,"phpcs.executablePath": "/home/qg/.config/composer/vendor/bin/phpcs","phpcs.standard": "PSR12","phpcs.ignorePatterns": ["*/vendor/*","*/cache/*","*/view/*","*/xview/*"]
忽略 psr12规范开始
// @codingStandardsIgnoreStart
结束忽略
// @codingStandardsIgnoreEnd
[PHP Debug]
php.ini 中配置
[xdebug]
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=192.168.1.91 ; 开发机的IP 取 vscode IDE 的电脑IP
xdebug.remote_port=9003
xdebug.idekey=vsc
; 临时开启调试日志,一般刚安装时用, xdebug 正常用,注释掉它
;xdebug.log=/home/wwwroot/debian_logs/xdebug.log
.vscode/launch.json
{"version": "0.2.0","configurations": [{"name": "Listen for PHP Xdebug","type": "php","request": "launch","port": 9003,//"log": true,"externalConsole": false,"pathMappings": {"/home/wwwroot/xmvc": "${workspaceFolder}"},"xdebugSettings": {"max_data": 65535,"show_hidden": 1,"max_children": 100,"max_depth": 5}}]
}