You can debug an application running on the PhpStorm built-in web server or on an external server.
To enable remote debugging in Firefox
Open your Firefox browser, click on the toolbar, and go to Development Tools pane opens.. The
On the toolbar of the pane, click , select Settings from the list, and then select the Enable browser chrome and add-on debugging and Enable remote debugging checkboxes under Advanced Settings.
To restart Firefox with the debugger server
Open the Terminal tool window (Alt+F12) and type
start firefox --start-debugger-server <port number>at the command prompt. Later you will specify this port number in the run configuration. You can set any port number, however it is recommended that you use 6000 and higher.
For versions 61 and earlier you do not need to restart Firefox.
Just go toand type
listen <port number>in the console that opens at the bottom of the browser.
To debug an application
Create a debug configuration of the type Firefox Remote: from the main menu, select , click on the toolbar and select Firefox Remote from the pop-up list.
In the Run/Debug Configuration: Firefox Remote dialog that opens, type
localhostin the Host field. In the Port field, type the port that you specified when you enabled remote debugging in Firefox. The default value is
Open your application in Firefox. The browser shows the application after the code execution, that is, the breakpoints you set have no effect yet.
Choose the newly created configuration in the Select run/debug configuration drop-down list on the toolbar and click .
In the dialog that opens, click OK to allow incoming connection from the browser.
Refresh the application page in the browser: the page shows the results of code execution up to the first breakpoint.
Suppose you have a simple application that consists of two files: index.html and index.js file, where index.html references index.js. This example shows how you can debug the application when it is running on the PhpStorm built-in server.
In the Terminal tool window (Alt+F12, type
start firefox --start-debugger-server 6000at the command prompt.
Set the breakpoints in index.js.
Create a FireFox Remote debug configuration, type
6000in the Host and Port fields respectively:
Open index.html in the editor, select Open in browser from the context menu, and then select Firefox from the list: The browser opens showing the application running on the PhpStorm port (currently
From the list on the toolbar, select the index_firefox_remote configuration and click : Click OK in the Incoming Connection dialog that opens: Refresh the application page in the browser.