0

I've recently had to swap over to a MacOS for development. Previously I had Xdebug running fine and it's such a massive help that I want to use is again.

I followed the Mac/homebrew instructions here: https://xdebug.org/docs/install#pecl with some more information that I found here: https://xdebug.org/docs/install#configure-php

php -v:

Cannot load Xdebug - it was already loaded
PHP 7.4.27 (cli) (built: Dec 16 2021 18:02:37) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Xdebug v3.1.2, Copyright (c) 2002-2021, by Derick Rethans
    with Zend OPcache v7.4.27, Copyright (c), by Zend Technologies

In my php.ini (I double checked that it was the correct one) I appended zend_extension=xdebug

I am running my site on a docker setup, and am using PhpStorm, here are the settings:

enter image description here

enter image description here

I have the Xdebug extension installed in Chrome and have made sure that PhpStorm is listening. However, when I put a breakpoint in my home controller and navigate to that page, the page loads without any breakpoints being hit.

phpinfo() also shows that xdebug is loaded: enter image description here enter image description here enter image description here

I've noticed that the xdebug version shown in the phpinfo dump does not match the version of xdebug I downloaded and installed:

enter image description here

Skytiger
  • 1,745
  • 4
  • 26
  • 53
  • 1
    What have you tried to resolve the problem? PHPStorm has a built-in validator for the configuration (Run > Web Server Debug Validation), what does that tell you? – Nico Haase Jan 18 '22 at 09:39
  • 1
    You say *"I am running my site on a docker setup,"* -- good. Then your first screenshot that shows the the Remote PHP Interpreter (from that Docker image) -- it shows that Xdebug is not detected there... So how do you expect Xdebug to work if it's not installed/activated/configured in your Docker image? – LazyOne Jan 18 '22 at 09:39
  • @NicoHaase When I run the validator I get told the specified URL is not reachable. I've set up mappings (tried different variations) with no success. The site itself works perfectly other than Xdebug not apparently being active. – Skytiger Jan 18 '22 at 19:14
  • @LazyOne I have Xdebug set up in my docker image, that's the problem I'm having - it's like it's not being detected or something, and I'm not sure what I've done wrong. Any advice you might have would be welcome. – Skytiger Jan 18 '22 at 19:16
  • 1
    @Skytiger *"I have Xdebug set up in my docker image"* Double check that. Make some `test.php` script and call `xdebug_info();` there and provide the output. Call it via CLI and via browser. You may have different configs in those environments. PLUS, the PHP version in that image differs to your `php -v` output. Sadly I cannot say why the IDE shows "not installed" if i's actually installed there. But speaking in general: perhaps PhpStorm does not handle the entry point properly (that sets up some stuff needed later for PHP/Xdebug)... – LazyOne Jan 18 '22 at 19:30
  • @LazyOne I've added a screenshot of my phpinfo showing that xdebug is loaded. When I try to use xdebug_info() an error is thrown: `Fatal error: Uncaught Error: Call to undefined function xdebug_info()`. – Skytiger Jan 18 '22 at 19:55
  • 2
    1) *"Call to undefined function xdebug_info()"* That's because it's Xdebug v3 only. Can you upgrade your Xdebug to v3? v2 is no longer supported (and you do not even have the latest 2.9.x version anyway) and v3 is a bit easier to configure and troubleshoot. 2) In any case: please show the **whole** Xdebug section of `phpinfo()` output. That's to see the live config values. 3) What about difference in PHP versions? Any notes on that? – LazyOne Jan 18 '22 at 20:04
  • @LazyOne I've added the full xdebug session. Thanks for spotting that version of xdebug, I didn't notice that. Bit confused because (see the last screenshot in the post) I downloaded xdebug 3.1.2 and installed that, so I have no clue where this older version is coming from... – Skytiger Jan 18 '22 at 20:14
  • 1
    Please show what `phpinfo()` topmost table has (captured via web page) -- want to see the whole table. In particular: what PHP version and Xdebug it reports, what config files are used? Now please run `php -v` and `php --ini` in CLI and show their output -- need to compare that info with what web page reports. – LazyOne Jan 18 '22 at 20:41
  • 1
    The point is: you may have multiple PHP installations there or different php.ini/config files (the usual case for Linux boxes these days; not so sure about docker images). How to fix this -- I cannot tell you (since I do not know your images/how you build them etc). – LazyOne Jan 18 '22 at 20:43
  • 1
    In any case: enable Xdebug log -- when Xdebug sees "debug me" flag or is configured to debug every single request (not your case as per Xdebug live config) it will write the log into that file (what IP:port it tries to connect to and what the response is etc). If no log is created then Xdebug is not active (is not trying to debug) or permissions issue. general info (Xdebug v3 but still): https://www.youtube.com/watch?v=IN6ihpJSFDw – LazyOne Jan 18 '22 at 20:46
  • @LazyOne Again, thanks for all the help. I've made a little bit of a breakthrough when I discovered the docker setup had some issues. They've since been fixed and I've gotten xdebug to start logging. – Skytiger Jan 19 '22 at 00:33

0 Answers0