Welcome to PHP Tools for Visual Studio. The following guide will help you with the basics, so you can quickly start working with PHP in Microsoft Visual Studio. Show
Getting to know the IDEThe Visual Studio main window is divided into several areas - menu bar, status bar, editor area, side panel containing the Solution Explorer, and various toolbars. All the positions can be changed. The following image describes the default layout. When you launch Visual Studio, you are welcomed with the Start Page. This allows you to open recent projects or create new ones quickly. When a project is opened, you can see the files that are a part of the project in the Solution Explorer. The Solution Explorer allows you to manage, search and open files, their properties and the project properties. The editor area contains opened files. It allows you to see and modify the content, and take advantage of advanced IntelliSense features, navigation features, syntax highlighting, live error detection and more. First PHP projectMost of the features in Visual Studio work within the context of a project. Debugging, IntelliSense, testing or configuring web server depends on a PHP project. The project corresponds to a single application or a library, it can be bound to a source control or configured to publish modified files onto a remote server. Projects in Visual Studio work with a local copy of your files. To push them on a server, you have to deploy your files - either by configuring automatic publish or by your own. There are several ways to create a new project in Visual Studio by:
New PHP Project from ScratchAn empty PHP Project is the simplest way of getting started with PHP Tools. Go to 'Menu | File | New | Project' and look for 'PHP' group. Find the project template you need and confirm. Additional files and directories can be added in various ways:
New Project in an Existing FolderIf you already have files in a local folder, you can create PHP Project in that
folder with all the files included. Navigate to Importing Local Files to a ProjectIf you already have a project, you can add existing files. See New PHP project from scratch for more information. Editing a PHP FilePHP Tools provides Visual Studio with a smart editor of PHP files. This allows you to work with great overview of your code, taking advantage of navigation bar, outlining, syntax highlighting; even with PHP, HTML, JavaScript or CSS mixed together, smart auto-completion Ctrl+Space taking into account the current code context, tooltip assistance, help integration F1, jump to definition F12 and live error underlining helping you to build error-free code. Built-in code snippets help you to write code fast avoiding typos. You can insert a code snippet Ctrl+K,X like new function body, for loop, try/catch construct and more to speed up your development. Newly inserted snippet is automatically formatted and cursor position moved directly inside the new code so you can type your code instantly. Moreover selected area of a code can be surrounded by a snippet Ctrl+K,S to avoid the need of copy-pasting and other refactoring. Run and Debug Your PHP ProjectOnce you have your PHP Project, you can run the application and debug. Debugging allows you to run the application and stopping on breakpoints F9, stepping on the next line F10, inside a function call F11, out of the function call Shift+F11 or inspecting and modifying variables. You can see e.g. local variables, super-global variables and current call stack. To run and debug the project, ensure it is properly configured (see below) and press F5 (or in Configuring PHPRunning the application locally requires properly configured PHP. To enable support for debugging, PHP extension Xdebug has to be installed and configured as well. PHP Tools help with the setup in two ways. Once you start your first application F5 and there is no valid PHP installation found, you can download and setup a recommended version of PHP with pre-configured Xdebug within one click from Microsoft Web Platform Installer. This is the most recommended option for most users. For users with custom requirements or requiring to use their existing PHP installation, PHP Tools help by checking the configuration and suggesting recommended fixes eventually. The issues dialog is shown automatically if there is an issue with configuration during the project startup. It can also be invoked manually from A list of PHP installations and their configuration can be found in Remote Debugging and Custom Web ServerTo run the application on a remote server or locally using a not-listed Web Server, go to project properties. Select Custom Web Server and enter its URL. In this case, PHP and Xdebug configurations are not checked whether they are installed or configured properly. You have to make sure that:
Test Your ApplicationPHP project integrates into Visual Studio Test Explorer. Go to Within the window, you can start or debug your test cases using built-in PHP Unit framework.
CustomizationThe Visual Studio environment is fully customizable. Most common tasks you may want to customize are listed below. File Extension Being Opened by PHP EditorIn addition to default .php file extension, you can
configure other file extensions to be edited with PHP editor capabilities. This is useful when you work on projects using non-standard file extensions for PHP script file, like .php5, .inc or .module. Go to Fonts and ColorsPHP Editor respects current users color scheme. Any color in the editor or in Visual Studio environment itself can be configured. Go to Keyboard MappingsPHP Tools respects the Visual Studio keyboard scheme. Shortcuts used to
work with your projects and editor can be managed in PHP Editor OptionsOptions of PHP Editor includes adjustment of code formatting behavior, change tab sizes, fine-tune IntelliSense, disable outlining of various code blocks and more. Go to That's ItThank you for reading our quick start guide. There is much more you can do with Visual Studio and PHP Tools. For more tips and/or questions, please see the rest of the documentation and the product's features page. Can you develop PHP in Visual Studio?PHP in Visual Studio Code. Visual Studio Code is a great editor for PHP development. You get features like syntax highlighting and bracket matching, IntelliSense (code completion), and snippets out of the box and you can add more functionality through community-created VS Code extensions.
How do I run a PHP project in Visual Studio?How to run PHP in Visual Studio Code on Windows 11. Step 1:Download PHP For Windows 11. ... . Step 2: Extract Zip File. ... . Step 3: Set Up Environment Variables. ... . Step 4: Check PHP VERSION. ... . Step 5: Install PHP Extensions in Visual Studio Code on Windows 11. ... . Step 6: Run PHP in Visual Studio Code on Windows 11.. How do I start a PHP project?Step 1: First of all, open the Apache Friends website and download XAMPP for Windows, and install it. Step 2: Start the XAMPP Program Control Panel. Click on the “Start” button next to the “Apache” to start your Apache Web Server. Also, start “MySQL” if your PHP programs depend on a MySQL database to run.
How run PHP and HTML together in Visual Studio Code?Open PHP/HTML/JS In Browser. Click the button Open In Browser on StatusBar.. In the editor, right click on the file and click in context menu Open PHP/HTML/JS In Browser.. Use keybindings Shift + F6 to open more faster (can be changed in menu File -> Preferences -> Keyboard Shortcuts ). |