Xdebug: confused about PhpStorm installation/configuration
I'm very confused about installing and configuring Xdebug for use with PhpStorm. A few days ago, I might have just written configuring because I already had Netbeans working with Xdebug, But then messages from Xdebug, and also the way the original Ubuntu Xdebug installation was done have added to my confusion. There are a quite a few moving parts.
First, what I'm trying to get working. PhpStorm 2018.2 running on Windows 10, with files served by a Ubuntu 18.04 server for web applications. AFAIK, I don't need a CLI PHP interpreter setup in PhpStorm for this configuration. Or do I? Messages from PhpStorm didn't make it clear.
When I tried to get this all working a week or so ago, Xdebug told me - the wizard I think - that PHP 5.6 wasn't supported. I believe this is new because it was fine earlier. The reason that I had PHP 5.6 running for some of the virtual hosts on the Ubuntu server is that they are running WordPress development and there's an old plugin that doesn't work with PHP 7.2. Fair enough. What I'm really wanting to work on isn't WordPress, and I can resolve that issue later. My top priority is getting PhpStorm able to debug something.
I switched the PHP version on the virtual host I wanted to use - to PHP 7.2.8-1, running as FPM/Fast CGI.
Back to PhpStorm. I was able to get the debug configuration to validate and showing PHP 7.2. But when I try to debug a file I get the following message:
SSH_MSG_DISCONNECT:2 Too many authentication failures. To fit it change project interpreter or check settings. [underlines are links in PhpStorm]. Change takes me to the CLI interpreter - which as I wrote I don't understand why I need to set up. The PHP version shown is 5.6, corresponding to the version I can see on the Ubuntu server. The check settings link brings up a window titled CLI Interpreters, with the SSH button set. And I'm totally unsure what to do about any of it.
Next step try to run the Xdebug wizard as suggested elsewhere in the PhpStorm documentation. The wizard tells me that I'm not running the latest version of Xdebug (2.6.1) which was released very recently. The installation instructions aren't clear at all - particularly on where to place the files. I installed the earlier version (2.6.0) using Synaptic on Ubuntu with the php-xdebug package.
Rereading what I just wrote (sorry about the length), it seems that Xdebug 2.6.1 is a bit of a red herring, and while it would be nice to have the Xdebug wizard say everything is fine, the more immediate issue is the PhpStorm configuration for the deployment server. I'll dive into that again, but if anyone can share guidance I'd appreciate it.
Thanks!
请先登录再写评论。
Hi there,
1) What are you trying to debug -- a web page or a CLI script (or both)?
2) You do not need local PHP Interpreter if you do not plan to execute anything local. But it will be needed if you plan to run local PHPUnit tests, CodeSniffer / Composer integrations and other tools that require PHP.
3) You do not need any PHP Interpreter configured in PhpStorm if you plan to debug web pages -- they will be handled by your web server (nginx + php-fpm as I understand) and IDE is unable to influence it anyway (provide own starting config options etc).
4) Cannot really comment on Xdebug Wizard -- never used it (no real need -- it's for those who want simplify their life and pick the right binaries / basic setup without reading all the docs and getting into the details). But yes -- Xdebug Wizard now covers PHP 7.x only -- it's just to encourage people to move from old and slower 5.x version, config wise it will be the same.
In general: https://confluence.jetbrains.com/display/PhpStorm/Debugging+with+PhpStorm
Thanks Andriy - you've helped clarify a couple of things. To respond to your points.
1) I'm trying to build/debug web applications, not CLI scripts.
2) What you wrote about using a local PHP interpreter to run local testing makes sense. I'm still learning about the aspects of PhpStorm and other IDEs beyond coding and debugging.
3) My LAN web server runs Apache not nginx, and Apache is also deployed on the development servers. I don't quite understand your point about the IDE not being able to influence the web server, but perhaps I'm misreading what you wrote. I've been reading more about debugging with PhpStorm - in particular extensions for browsers so that initiating a debug session is simplified. In this regard, PhpStorm seems more complicated than NetBeans (for which I just need to tell it to debug - the Xdebug part happens transparently).
4) Your comment about the Xdebug Wizard is answer enough. After looking more closely at the Xdebug installation process I realized that the Ubuntu package didn't much. There appears to be just a single module that got installed (configuration of .ini files is another matter). So I compiled the 2.6.1 module, copied it to the right place, and then reloaded phpinfo.php and reran Xdebug Wizard which passed. One more possible issue resolved, so back to PhpStorm itself for the deployment and debug settings.
>I don't quite understand your point about the IDE not being able to influence the web server, but perhaps I'm misreading what you wrote
If you want to execute/debug some CLI script then it can be initiated from within the IDE -- it will execute your PHP executable and can pass any config parameters if needed in command line (e.g. enable xdebug, specify xdebug host/port etc).
But if it's a web page... then processing PHP code is controlled by your web server (in your case Apache -- it is the one that launches PHP executable/module for that; main config is done via php.ini) and PhpStorm cannot control this aspect (it cannot say: "hey Apache, load currently disabled xdebug extension for me when processing this URL").
With that in mind: there is no need defining PHP Interpreter if it's just web page debugging.
>In this regard, PhpStorm seems more complicated than NetBeans (for which I just need to tell it to debug - the Xdebug part happens transparently).
You can initiate web page debug from IDE as well (e.g. Run/Debug Configuration of "PHP Web Page" type) -- IDE will add xdebug specific parameter to the URL. Browser extension is better though (IMO) -- more flexible; enable/disable debug me flag (cookie) only when needed etc.
Plus, do not forget that different people have different setups and requirements for debugging (especially remote one). More detailed setup allows to cover more cases/situations.
You are new to this IDE (IDEA platform in general) so it takes time to get the idea, get know the stuff etc. Once you learn it you will see that setting up debugging on IDE side is nothing special at all (minimal efforts) -- in most cases configuring xdebug on php.ini side / open firewall ports etc is where the time is spent.
Thanks for your patience Andriy. I had to go back a few steps on the server because of some changes I'd made, but now NetBeans debug is working again with PHP 7.2.
It seems that using the browser extensions and enabling/disabling through the browser is a little different than the way NetBeans works for debugging when I can see a web page opened that initiates debugging separately from the page I'm trying to debug - or perhaps it's the beginning of the page. It doesn't matter much as I'm trying to get PhpStorm working, and the only reason to use NetBeans is to compare what happens.
Can you tell me what I'm doing wrong with the following steps?
I've messed something up and now it doesn't validate. I'm running out of brainpower, but before I submit this, one last question. Am I correct in thinking that PhpStorm uploads to the remote server via FTP/FTPS/SFTP (for the validation script for example) and not using a mapped drive for a remote server? If so, I misinterpreted.
So far your Xdebug config is fine (they are basically defaults except port number).
>I click the Green bug in the toolbar, or right click in the script and choose "debug " scriptname
When you do that .. and you do not have any Run/Debug Configuration already selected .. then it will attempt to debug PHP script in CLI mode (Run/Debug Configuration of "PHP Script" type) where you need PHP Interpreter configured (which can be Local or Remote).
Since you went the "Zero config" way (where you initiate debug from your browser) and you want to debug a web page... you do not need to create any Run/Debug Configurations. https://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm
>Am I correct in thinking that PhpStorm uploads to the remote server via FTP/FTPS/SFTP (for the validation script for example) and not using a mapped drive for a remote server?
I'm not using such stuff myself (no need at all for me) .. but it should be using your current Deployment entry (selected as Default for this project) which could be FTP / SFTP / FTPS or local/mapped folder.
I finally made some progress. Debugging a PHP file with output and variables visible in PhpStorm and output in the browser! It looks like I should do some clean up to minimize further confusion (repeating mistakes), but at last I have something I can work with.
THANKS!