

PHP in Visual Studio
source link: https://devblogs.microsoft.com/visualstudio/php-in-visual-studio/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

PHP in Visual Studio

Mads Kristensen
PHP is one of the most popular programming languages for server-side web development. It’s used in many frameworks and CSMs like WordPress, Laravel, Symfony, and others which are behind a sizable chunk of the Internet.
Visual Studio is a powerful IDE, but its focus didn’t align with some languages, PHP being one of them. As time progressed more languages found their way to Visual Studio, like Python and eventually PHP. A Prague-based company called DEVSENSE developed an extension called PHP Tools for Visual Studio which has been available in the Visual Studio ecosystem for over a decade.
Since its inception PHP Tools for Visual Studio was a paid extension, offering a free trial. Now, that’s changed. DEVSENSE is releasing a big part of their offering as a free extension, leaving some features as paid ones. That allows PHP developers to work in Visual Studio and take advantage of all the great stuff which is available.
That means developers will get IntelliSense, formatting, project system, on-the-fly code analysis, composer (PHP dependency management) integration and other advanced editor-related features for free. In the latest version, PHP Tools support PHP 8.2 which hasn’t been released officially yet, and other things like generics which are a must-have for frameworks like Laravel. Other features like debugging, refactoring, unit testing, and code lens are available in the premium offering. The detailed comparison matrix can be found at https://www.devsense.com/purchase
Quick start
First, install PHP Tools for Visual Studio
Create your PHP project
After the installation:
- Select Create a new project from the start page or File > New > Project… from the title bar
- In the language combo box select PHP, select PHP Web Project, then select Next
- Name your project and select Create.
- At this point, you can select the project template. Let’s choose Empty Web Site and select Next:
- Now, you can select which PHP version to set for the project. For this short tutorial, we can go with PHP 8.1 and select Finish. PHP Tools will check your environment and install and configure PHP which is set up in the project:
Use the PHP Editor in Visual Studio
When the installation is finished, the project will open. In the editor, you can hover over any symbol to get a tooltip. Or press Ctrl + Space to see the IntelliSense for the current context.
Run and Debug PHP in Visual Studio
Place a breakpoint F9 and hit F5 to run the project and start debugging. The server which is configured in the project (by default it’s PHP’s built-in Web server) will run and a browser opens. Then the breakpoint will get hit.
Congratulations! You are debugging PHP in Visual Studio.
This was a simple walkthrough of how PHP Tools for Visual Studio can be used where you have one project in the solution. A more complex setup is possible: developers can add PHP projects to their existing solutions (*.sln) – having one IDE should make their life easier, or they can work with PHP just by opening a folder. More tutorials can be found on DEVSENSE’s documentation.
Next steps
If PHP development in Visual Studio is interesting to you, please install PHP Tools for Visual Studio and make sure to let the authors know how you like it, what features you are missing or if you run into anything that could be further improved. You can reach them at DEVSENSE’s PHP Tools Community Forum.
Mads Kristensen Principal Product Manager, Visual Studio
Follow
Recommend
-
191
博客园 博客园用户登录...
-
233
404 页面不存在 404. 抱歉,您访问的资源不存在。 可能是网址有误,或者对应的内容被删除,或者处于私有状态。 代码改变世界,联系邮箱 [email protected]
-
187
Open Sourcing the Java Debugger for Visual Studio Code Xiaok...
-
203
-
150
October 2017 (version 1.18) Update 1.18.1: The update addresses these issues. Downloads:
-
165
平时工作做C/C++方面的开发更多还是在Windows下使用Visual Studio,几乎都是做跨平台开发,Windows上跑通后Linux上编译发布,基本上都没什么问题,如果的确需要调试,有VisualGDB的存在也很方便;但在macOS下使用过IDE性质的XCode,CLion,Qt Creator,也使用...
-
189
Out of the blue, Microsoft jumps into the editor wars with an incredible offering that gives Sublime Text an overwhelming run for its money. In fact, it just might surpass it! So come along, as I demonstrate the ins, the outs, the tips, the tech...
-
149
博客园 博客园用户登录...
-
156
博客园 博客园用户登录...
-
12
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK