Access the page you want to debug and the execution will stop at the specified breakpoint. Once installed, click on the bug button and select the Debug option from the drop-down, then the icon will turn green. Install the Xdebug helper extension for Chrome. This normally only happens the first time after setting up the configuration. You will notice that PHPStorm will prompt us with an incoming connection dialog that we need to accept before carry on. Place a breakpoint in your code, in a place you know for sure will be executed. Now we need to start listening for PHP debug connections in PHPStorm, to do so click on the phone icon and turn it on. When this has successfully connected, you do not need to do anything else, just leave the SSH tunnel open. $ ssh -R 9000:localhost:9000 -p remote_ssh_port To do this, we will need to type the following into the terminal: Remote debugging in PhpStorm via SSH tunnel The idea is that we create a “virtual” TCP port on the remote server that sends its traffic to a TCP port on our own machine, tunneling traffic over SSH. What we want to do is connect to the remote machine over SSH and setup port forwarding for port 9000 (Xdebug) or port 10137 (Zend Debugger). You will need to have this tunnel open in order to debug with PHPStorm. Now that we have everything configured, we will need to open a SSH tunnel and set up port forwarding for port 9000 (or the one specified in the xdebug.ini file) to connect to your remote server. Note that we need to explicitly save the file in order to upload it to the server. Now, if you modify a file and save it, you will see that a new panel will appear with the file transfer information. You will find that the files hosted within the deployment path on server are now copied into the local path we specified.
PHPSTORM UPLOAD ON SAVE DOWNLOAD
Right-click on the project root folder and select the option Deployment > Download from PotatoServer: This will upload the given file to the server after explicitly saving it.Ĭlick on the OK button and go to the Project View. Now, in the PHPStorm preferences, go to Build, Execution, Deployment > Deployment > Options, and select the option On explicit save action. Just the web path on the server (not really necessary for debugging) Path to the sources in your remote server, in this case ‘/’ because we set the path to our source in the Root path field in the previous tab This is the path of the project you just created Click on the Mappings tab, and fill in the blanks like so: The next step is to configure the mappings. Just the root of the web server (this one is optional, and not really required)
PHPSTORM UPLOAD ON SAVE CODE
The path where our code is hosted in the remote server We then need to configure the connection as follows: Then the name of the server will be shown in bold: With this complete, we will click on the icon to set it as a default deployment server for this project. Specify a relevant name, and set the type option to SFTP. To do this, we need to open the PHPStorm preferences and go to Build, Execution, Deployment > Deployment, and click on the + button as it is shown in the screenshot below: Now we need to setup our deployment and mapping configurations. We then click on the OK button in the right-hand bottom corner, and our New Project window should look like this:įinally, click on the Create button. Now, your Default CLI Interpreters configuration should look like this: The path in the server where PHP executable is, normally /usr/bin/php The port used to connect to your remote server via SSH In the Configure Remote PHP Interpreter window, select the SSH Credentials option, and fill the blanks as it is shown below: Then you will be greeted with some options. In the Default CLI Interpreters window, click on the + button: as it is shown in the following screenshot: In this new project, we will need to use the remote CLI interpreter on the server. First of all we will need to create a new empty PHP project. Now we will need to configure some bits in PHPStorm. Configuring PHPStorm Creating a new empty project It’s fine, later on we will use an SSH tunnel to redirect the traffic from port 9000. You will need to restart services such as Nginx, Apache and/or FPM on your server to apply these configuration changes.