{"id":240116,"date":"2022-11-03T08:00:29","date_gmt":"2022-11-03T15:00:29","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/visualstudio\/?p=240116"},"modified":"2022-11-02T09:21:53","modified_gmt":"2022-11-02T16:21:53","slug":"php-in-visual-studio","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/visualstudio\/php-in-visual-studio\/","title":{"rendered":"PHP in Visual Studio"},"content":{"rendered":"<p>PHP is one of the most popular programming languages for server-side web development. It&#8217;s used in many frameworks and CSMs like WordPress, Laravel, Symfony, and others which are behind a sizable chunk of the Internet.<\/p>\n<p>Visual Studio is a powerful IDE, but its focus didn\u2019t 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\u00a0PHP Tools for Visual Studio\u00a0which has been available in the Visual Studio ecosystem for over a decade.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/11\/editor.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-240121\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/11\/editor.png\" alt=\"Image editor\" width=\"624\" height=\"302\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/11\/editor.png 624w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/11\/editor-300x145.png 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/a><\/p>\n<p>Since its inception PHP Tools for Visual Studio was a paid extension, offering a free trial. Now, that&#8217;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.<\/p>\n<p>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&#8217;t been released officially yet, and other things like\u00a0<a href=\"https:\/\/blog.devsense.com\/2022\/update-php-generics\">generics<\/a>\u00a0which 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\u00a0<a href=\"https:\/\/www.devsense.com\/purchase\">https:\/\/www.devsense.com\/purchase<\/a><\/p>\n<h2><strong>Quick start<\/strong><\/h2>\n<p>First, install\u00a0<a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=DEVSENSE.PHPToolsforVisualStudio2022\">PHP Tools for Visual Studio<\/a><\/p>\n<h3><strong>Create your<\/strong><strong> PHP project<\/strong><\/h3>\n<p>After the installation:<\/p>\n<ul>\n<li>Select <em>Create <\/em><em>a new project <\/em>from the start page or <em>File &gt; <\/em><em>N<\/em><em>ew <\/em><em>&gt; <\/em><em>P<\/em><em>roject<\/em><em>&#8230; <\/em>from the title bar<\/li>\n<li>In the language combo box select <em>PHP, <\/em>select\u00a0<em>PHP Web Project<\/em><em>, then select <\/em><strong>Next<\/strong><\/li>\n<li>Name your project and select <strong>Create<\/strong>.<\/li>\n<li>At this point, you can select the project template. Let&#8217;s choose <em>Empty Web Site <\/em>and select\u00a0<strong>Next:\n<a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/11\/new-project.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-240118\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/11\/new-project.png\" alt=\"Image new project\" width=\"624\" height=\"499\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/11\/new-project.png 624w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/11\/new-project-300x240.png 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/a>\n<\/strong><\/li>\n<li>Now, you can select which PHP version to set for the project. For this short tutorial, we can go with\u00a0<em>PHP 8.1<\/em> and select <strong>Finish<\/strong>. PHP Tools will check your environment and install and configure PHP which is set up in the project:\n<a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/11\/install.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-240117\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/11\/install.png\" alt=\"Image install\" width=\"624\" height=\"499\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/11\/install.png 624w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/11\/install-300x240.png 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/a><\/li>\n<\/ul>\n<h3><strong>Use the <\/strong><strong>PHP Editor in Visual Studio<\/strong><\/h3>\n<p>When the installation is finished, the project will open. In the editor, you can hover over any symbol to get a tooltip. Or press <kbd>Ctrl<\/kbd> + <kbd>Space<\/kbd> to see the IntelliSense for the current context.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/11\/tooltip.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-240119\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/11\/tooltip.png\" alt=\"Image tooltip\" width=\"556\" height=\"256\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/11\/tooltip.png 556w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/11\/tooltip-300x138.png 300w\" sizes=\"(max-width: 556px) 100vw, 556px\" \/><\/a><\/p>\n<h3><strong>Run and Debug PHP in Visual Studio<\/strong><\/h3>\n<p>Place a breakpoint\u00a0<kbd>F9<\/kbd>\u00a0and hit\u00a0<kbd>F5<\/kbd>\u00a0to run the project and start debugging. The server which is configured in the project (by default it&#8217;s PHP\u2019s built-in Web server) will run and a browser opens. Then the breakpoint will get hit.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/11\/breakpoint.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-240120\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/11\/breakpoint.png\" alt=\"Image breakpoint\" width=\"362\" height=\"157\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/11\/breakpoint.png 362w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2022\/11\/breakpoint-300x130.png 300w\" sizes=\"(max-width: 362px) 100vw, 362px\" \/><\/a><\/p>\n<p>Congratulations! You are debugging PHP in Visual Studio.<\/p>\n<p>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) \u2013 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 <a href=\"https:\/\/docs.devsense.com\/\">DEVSENSE&#8217;s documentation.<\/a><\/p>\n<h2><strong>Next steps<\/strong><\/h2>\n<p>If PHP development in Visual Studio is interesting to you, please install\u00a0<a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=DEVSENSE.PHPToolsforVisualStudio2022\">PHP Tools for Visual Studio<\/a> 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\u00a0<a href=\"https:\/\/community.devsense.com\/\">DEVSENSE&#8217;s PHP Tools Community Forum<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP is one of the most popular programming languages for server-side web development. It&#8217;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\u2019t align with some languages, PHP being one of them. As [&hellip;]<\/p>\n","protected":false},"author":642,"featured_media":240119,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1388,155,1029],"tags":[6863],"class_list":["post-240116","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-extensibility","category-visual-studio","category-web","tag-php"],"acf":[],"blog_post_summary":"<p>PHP is one of the most popular programming languages for server-side web development. It&#8217;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\u2019t align with some languages, PHP being one of them. As [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/240116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/users\/642"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/comments?post=240116"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/240116\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media\/240119"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media?parent=240116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/categories?post=240116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/tags?post=240116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}