VSCODE + SSH for PHP 配置

 清理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.debian12
    HostName vm.debian12
    User root
    Port 22
    #PreferredAuthentications password
    IdentityFile 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
            }
        }
    ]
}

相关推荐

  1. Git<span style='color:red;'>配置</span>

    Git配置

    2024-05-11 10:14:03      62 阅读
  2. Redisson配置

    2024-05-11 10:14:03       59 阅读
  3. nginx配置

    2024-05-11 10:14:03       61 阅读
  4. VLAN配置

    2024-05-11 10:14:03       55 阅读
  5. XMLParser配置

    2024-05-11 10:14:03       57 阅读
  6. Redis 配置

    2024-05-11 10:14:03       47 阅读
  7. NAT<span style='color:red;'>配置</span>

    NAT配置

    2024-05-11 10:14:03      61 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-05-11 10:14:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-05-11 10:14:03       100 阅读
  3. 在Django里面运行非项目文件

    2024-05-11 10:14:03       82 阅读
  4. Python语言-面向对象

    2024-05-11 10:14:03       91 阅读

热门阅读

  1. MyBatis——MyBatis 核心配置文件

    2024-05-11 10:14:03       32 阅读
  2. 三生随记——耳机里的诅咒

    2024-05-11 10:14:03       25 阅读
  3. 2.mysql--备份恢复

    2024-05-11 10:14:03       33 阅读
  4. Spring Cloud LoadBalancer 4.1.2

    2024-05-11 10:14:03       23 阅读
  5. Acwing2024蓝桥杯并查集

    2024-05-11 10:14:03       150 阅读
  6. 什么是中间件

    2024-05-11 10:14:03       31 阅读