- 编辑器
- Visual Studio Code 基础
- 安装Visual Studio Code
- VS Code 扩展市场 VS Code Extension Marketplace
- 通过任务集成外部工具 Integrate with External Tools via Tasks
- 调试
- Why Visual Studio Code? - 为什么选用VSCode
- 版本控制(Version Control)
- Accessibility 易用性
- Editing Evolved - 与时俱进的编辑体验
- 定制化
- 定制化Visual Studio Code(Customize Visual Studio Code)
- 用户和工作区设置(User and Workspace Settings)
- VS Code 的快捷按键(Key Bindings for Visual Studio Code)
- 向 VSC 添加代码段(Adding Snippets to Visual Studio Code)
- Color Themes - 颜色主题
- Display Language - 语言区域
- 工具
- vsce - Publishing Tool Reference
- Yo Code - Extension Generator
- VS Code Extension Samples
- 技术支持
- Visual Studio Code FAQ
- Common Error Cases
- 如何升级到最新版 How to update to the latest release
- Requirements for Visual Studio Code
- 扩展
- Visual Studio Code 扩展 Extending Visual Studio Code
- 示例 - Hello World Example - Hello World
- 示例 - 单词数统计 Example - Word Count
- 示例 - 语言服务 Example - Language Server
- 示例 - 调试器 Example - Debuggers
- Running and Debugging Your Extension
- 安装扩展
- Extensibility Principles and Patterns
- Testing Your Extension
- Our Approach to Extensibility
- 扩展API
- 可扩展性参考
- 扩展清单文件 - package.json
- Contribution Points - package.json
- Activation Events - package.json
- vscode namespace API
- Complex Commands API
- Debugging API
- 语言
- 语言 Languages
- JavaScript
- 用C#进行工作 Working with C#
- C/C++ for VS Code (预览)(Preview)
- JSON
- VS Code对HTML的相关 HTML Programming in VS Code
- VS Code中的PHP编程 PHP Programming in VS Code
- VS Code 对 Python 的支持
- Markdown and VS Code - Markdown与VS Code
- Editing TypeScript
- CSS, Sass and Less
- 使用Docker工作
- 运行时
- Node.js Applications with VS Code
- ASP.NET Core with VS Code
- Unity Development with VS Code
- Office Add-ins with VS Code
- 开始(Getting Started)
VS Code中的PHP编程 PHP Programming in VS Code
对于PHP开发来说,Visual Studio Code是一个非常不错的编辑器。你可以体验到诸如语法高亮和括号匹配、代码提示以及snippet等特性。不仅如此,你还可以通过VS Code的社区获得更多功能性的扩展。
Visual Studio Code is a great editor for PHP development. You get features like syntax highlighting and bracket matching, IntelliSense, and snippets out of the box and you can add more functionality through community created VS Code extensions.
代码片段 Snippets
Visual Studio Code为PHP提供了一套通用的snippet集合。你只需要输入 kb(editor.action.triggerSuggest)
就可以得到与之上下文环境匹配的列表。
Visual Studio Code includes a set of common snippets for PHP. To access these, hit kb(editor.action.triggerSuggest)
to get a context specific list.
检查 Linting
VS Code使用PHP官方的linter(php -l
)来进行PHP语言的诊断。这意味着VS Code可以自动同步PHP官方Linter的更新。
VS Code uses the official PHP linter (php -l
) for PHP language diagnostics. This allows VS Code to stay current with PHP linter improvements.
这里提供了三条配置项来配置PHP linter:
There are three settings to control the PHP linter:
php.validate.enable
: 用于配置是否启用PHP linting功能。默认是启用的(Enabled)。php.validate.enable
: controls whether to enable PHP linting at all. Enabled by default.php.validate.executablePath
: 磁盘上的PHP可执行路径。如果PHP可执行路径不在系统路径上,则要自己手动配置该项。php.validate.executablePath
: points to the PHP executable on disk. Set this if the PHP executable is not on the system path.php.validate.run
: 用于配置linter的功能是通过“保存”(value:"onSave"
)触发还是“输入”(value:"onType"
)触发。默认是“保存”触发。php.validate.run
: controls whether the validation is triggered on save (value:"onSave"
) or on type (value:"onType"
). Default is on save.
设置PHP的可执行路径,打开User or Workspace Settings然后添加php.validate.executablePath
: To set the PHP executable path, open your User or Workspace Settings and add the php.validate.executablePath
:
{
"php.validate.executablePath": "c:/php/php.exe"
}
扩展 Extensions
在VS Code市场上你可以找到许多PHP相关的可用扩展,并且还有更多扩展正在陆续地再开发当中。你可以通过在VS Code中执行Extensions: Install Extension命令 (kb(workbench.action.showCommands)
输入 ext install
)来得到所有的可用扩展列表,再输入“PHP”即可显示与PHP相关的扩展列表
There are many PHP language extensions available on the VS Code Marketplace and more are being created. You can search for PHP extensions from within VS Code by running the Extensions: Install Extension command (kb(workbench.action.showCommands)
and type ext install
) then filter the extensions drop down list by typing php
.
调试 Debugging
VS Code支持通过XDebug来调试PHP,PHP Debug扩展。根据扩展的指令来配置XDebug使XDebug与VS Code协同工作。
PHP debugging with XDebug is supported through a PHP Debug extension. Follow the extension's instructions for configuring XDebug to work with VS Code.
下一步 Next Steps
阅读以下相关内容:
Read on to find out about:
扩展市场 - 浏览其他已分享的扩展
Extension Marketplace - Browse the extensions others have shared
调试 - 学习更多VS Code调试相关内容
Debugging - Learn more about VS Code debugging
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论