|This tutorial describes how to make use of the built-in webserver in PhpStorm.|
To be able to work with the built-in webserver in PhpStorm, a project has to be open. Make sure that the project has a PHP Interpreter configured under Settings / Preferences | Languages & Frameworks | PHP:
The easiest way to open the file from PhpStorm project is invoking Open in Browser | Browser ... action in the file context menu (in Project View toolbox) or in the View | Open in Browser | Browser ... menu:
Alternatively, you can just navigate to http://localhost:63342/<projectname>. For example when working in a project called HelloWorld, navigate to http://localhost:63342/HelloWorld/. This will serve our project files using the project root as the webserver's content root.
Built-in webserver behaves like a normal webserver, which means that it can be used for proper PHP debugging. Please make sure that either Xdebug or Zend Debugger debug extension is installed and configured for the PHP interpreter set for the project.
Debugging using the built-in webserver is the same as normal debugging described in Zero-configuration Web Application Debugging with Xdebug tutorial and other debugging tutorials.
Built-in webserver port can be always configured in Settings/Preferences | Build, Execution, Deployment | Debugger. The default port is 63342. Built-in webserver can also accept external connections when explicitly configured to do so (disabled by default due to security reasons).
When opening the browser and navigating to the project, an error may occur:
This error is displayed when you navigate to the built-in webserver and no PHP interpreter has been specified for the project. By clicking the link in the error message or by using Settings/Preferences | Languages & Frameworks | PHP, the PHP interpreter can be specified.