PHPStorm - Debugging starting with an HTML page

Hello…

I am running the current version of PHPStorm.

I am following an online course that is teaching me the use of PHP (I have done extensive web development but using .NET.).  With this course I have created two files in PHPStorm; CalculatorForm.html and Calculator.php.

With the first form (.html) I enter several numbers to have them computed by the PHP file (.php).

I am trying to run the debugger to validate that it works in such a configuration so that when I move onto developing a full web application with PHP I will understand how to use the debugger properly.  

I have set a breakpoint in the .php file.

However, when I attempt to run the application in “debug” mode, the application comes up properly with the display in the .html file but fails to stop at the breakpoint I have set in the secondary .php file.

I have not found any information on how to use the debugger in this situation but have attempted several edit-configurations for the running of the application in debug mode.

Can someone tell me what I am doing wrong here?

Thank you

 

 

 

0

Hello,

Could you please tell a bit more about your setup? Do I understand you correctly that you are using local web server, right?

I was wondering if you already familiar with the Zero-Configuration debugging concept:
https://www.jetbrains.com/help/phpstorm/zero-configuration-debugging.html

0

Hello Vasiliy…

Yes, I am aware of the Zero-Configuration debugging capability.

However, I have tried using every configuration for getting my debugger to work under the circumstances I described.

Yesterday however, I did set up my local IIS server to process PHP and finally got it working after several hours of research and tinkering.

Today, I am going to see if this resolves the debugging issue…

 

 

0

I tried the debugger again but this time with a properly configured server.  It still didn't work.

Here is the run-debug configuration I have been trying to work with…

 

No matter what I try or how I try it, I cannot get the debugger to work…  :-(

0

Hello Steve,

Thank you for your reply.
You have mentioned that you have already configured IIS, however, as far as I see on a screenshot, you are trying to address “localhost” on port 63342 which stands for the IDE built-in web server.

What “host:port” part of the URL  do you use on your IIS server? 
Have you already installed Xdebug there? Would it be possible to share `phpinfo()` output from your web-server?

You may just create a “.php” file with the single `phpinfo();` line and open it thru your web-server to get the output.

0

Hi Vasiliy…

I have attached the output of my “phpinfo.php” file…

https://1drv.ms/u/s!AnW5gyh0E3V-8GwjPiZmBoy88ADn?e=okm0BC   (download link)

Steve Naidamast / Sr. Software Engineer

 

 

 

0

Hi Steve,

Thanks for sharing the `phpinfo()` output. Please try the following simple test:

- Create a test.php file with one single line (let's say echo something), put a breakpoint on this line;
- Deploy it to your web-server (if you do not use in-place configuration);
- In IDE, go to “PHP > Servers” and remove all records leaving it empty;
- Enable the debugger extension in your browser and try to open the test file from your IIS web-server.

Would an ‘Incoming debug connection’ window appear and breakpoint hit? 

 

0

Hi Vasiliy…

I followed your recommended steps in your previous note and here are the results…

  • In PHPStorm I created a new project, which I called, PHPDebugTest
  • In this new project I added a new PHP file called, index.php, which is one of the default documents for my local IIS server
  • In the index.php file, the following code was entered…

               <?php
                        echo("Hello PHP !!!")
               ?>

  • I double-checked that my XDebug Extension was applied properly in PHPStorm
  • I also installed the XDebug extension for the Firefox Browser, which is my preferred browser
  • I first ran the project from my IIS server, which ignored the XDebug process and simply displayed the text from the “echo” statement
  • Notice that the ladybug in the highlighted red ellipse is green, meaning that XDebug was on
  • I next tested the debugger from within PHPStorm with the following result…

As you can see, the debugger stopped at the breakpoint line where the “echo” statement is.

The debugging of just PHP files from within PHPStorm appears to work as one would expect.

However, what I have been trying to do is start a session from an “index.php” file, which calls a PHP redirect by using the “header” statement to an HTML page that has no PHP code within it.  Thus this HTML page has the standard htm/html file extension.

Within the HTML page is a “SUBMIT” button, which posts to a second PHP file, where I set a breakpoint line within this second PHP file.

However, the breakpoint is never reached.  If I just run the project without attempting to debug it, everything works as expected.

If I run the project using XDebug actively, the debugger then simply ignores whatever it encounters and runs as if no debugging option had been set…

Steve Naidamast / Sr. Software Engineer

 

0

Hi Steve,

Thank you for the detailed reply.

Do you mind me asking if it is possible to share your test project privately? You may use JetBrains Upload services, just let me know the Upload ID afterwards:
https://uploads.jetbrains.com/

0

Hi Vasiliy...

I have uploaded my project in zip-file format.

The ID is...2023_12_02_xWv77cg8NUVkdqrLRV8CbB

There are some extra files in the project root that right now you don't have to be concerned with.

It is the "index.php" file that starts off the session that I have been testing the debugging process with.

The "index.php" file redirects to the "CalculatorForm.html" file.

In the "CalculatorForm.html" file there is a "SUBMIT" button, which posts to the "Calculator.php" file.

This sequence of events has always worked correctly.

However, when I attempt to debug the project, I can get to the breakpoint I set at the "Header" redirect line in the "index.php" file.

Once, the redirect is accomplished, the debugger no longer sees the rest of the project and subsequently does not pick up at a breakpoint that I set in the "Calculator.php" file.

Thank you for all your assistance...

Steve Naidamast / Sr. Software Engineer

 

0

Hello Steve,

Thanks for sharing the project!

There is a couple of things I would like to notice after inspecting it:

- There is a redirect to the incorrect/different server. In other words, redirect is being pointed to the IDE built-in web server, not your IIS server (mind the port):

- In “PHP > Servers”, your server record should have a web-server HTTP port, not the XDebug port:

 

I have managed to make your project debug work on my installation:

By doing these things:

- Changing redirect to my local web-server (that serves on TCP 81, you might need to change it to your IIS port):

- And adding my local web-server record with the correct port:

You may also untick the “Ignore external connections…” option to help IDE to populate the server record automatically:

Could you please try the abovementioned suggestions?

0

Hi Vasiliy…

Thank you for your updates.

I did implement them and these are my results…

  • I was not able to get PHPStorm to run the entire debugging processes if I started the session from the “index.php” file.  In this case, I was able to go into the “index.php” file and step through the code.  However, even using the “step into” option with the “F7” key, the IDE ignored the redirect to the “CalculatorForm.html” file and didn't even produce the web page in my browser.
  • When starting the session from the “CalculatorForm.html” file instead of from the “index.php” file, the “CalculatorForm.html” page was display in my browser and selecting the “SUBMIT” button then took me to the “Calculator.php” file where I was able to step through the code and see the results in the browser.

From my perspective, it does not appear that the PHPStorm documentation is concise enough to assist newcomers to this IDE to set up the debugging processes properly.

On the one hand, why doesn't XDebug work properly with the built-in web server?  So far, I have not been able to make this work yet, if in fact should work.

On the other hand, why does PHPStorm have two ways of setting up configurations for debugging purposes?  You have the “Settings” options with both the PHP options of “Debug” and “Servers” to configure.  And you also have an “Edit Configurations” under the “Run” drop-down menu.

So which am I supposed to use?  The “Settings” options appears to be for the IDE itself while the “Edit Configurations” entries appear to be for a single project.

I think one of these sections is still coming into conflict with the other but I am not sure which set of entries should be changed.

If I may suggest, this part of the PHPStorm IDE should be modified so that a new developer can simply select which debugger he or she wants to use and PHPStorm will do the rest by installing the selected debugger and configuring PHPStorm to use it correctly either within the IDE's web server or that of an external server, such as in my case with IIS.

As a long time Visual Studio user, I have never had an issue with using its debugger, no matter what type of application I was developing.  In Visual Studio we have either “Run (No Debug)” or “Run (Debug)”.  The developer selects the option and the rest Visual Studio takes care of.

Steve Naidamast / Sr. Software Engineer

 

0

Hi Steve,

Thank you for your detailed reply.

Here is a recording of how does it work on my side:
https://recordit.co/MNGB46s8na (sorry about the resolution, you might want to zoom out the page)

Am I missing something? Would it be possible to record your own screencast?
If you like, we may proceed in a support ticket, so you may share information that you may not like to share in public. It is possible to submit a support ticket via the “Help > Contact Support” option, just let me know the ticket number, so I could intercept it.

As for the Xdebug documentation and automated configuration, unfortunately, it is not as simple. Basically, the configuration process is two-sided and mostly, it requires configuration on a web server side. As all environments are different or even unique, there is no simple way for IDE to configure/install debugger remotely. We are still thinking what we can do about it and how to make this process smoother though. 

For the “Zero Configuration Debug” scheme, there is no need to use/edit “Run Configurations” and usually, it is enough to configure the debug extension on server, install browser add-on and tick the “Listen for incoming debug connections” button.  

0

Hi Vasiliy…

I hope I find you well…

I apologize for not getting back to you yesterday but I got really busy with things.

I will try to review your screen-cast later this afternoon.

I have no problem with continuing to correspond in this manner as there is nothing confidential about the PHP work I am currently doing.

However, I have been having some more success with the PHPStorm debugging processes.  I still have some more to do but it appears we are on the right track.

As to automating the process, I don't see any reason to have to set up a debugger against an actual web server if it is already working within the PHPStorm internal web server.  Visual Studio mostly uses just the locally installed IIS and there are no actual configuration issues to deal with.

As a result, attempting to do what PHPStorm currently does only makes the entire process far more complicated than it has to be…

Steve Naidamast / Sr. Software Engineer

0

Hi Vasiliy…

I got a chance to go through your screen-cast and what you demonstrated is exactly what I have been finally able to accomplish in PHPStorm.

Like I said in my previous email, I still have some tinkering to do but I think I am getting a handle on the PHPStorm debugging processes…

Steve Naidamast / Sr. Software Engineer

 

0

请先登录再写评论。