Jump to content

Trouble Debugging ProcessWire using XDebug + PHPStorm


FrancisChung
 Share

Recommended Posts

Hi there,

I'm a newbie and I'm trying to learn more about Processwire so I've setup XDebug + PHPStorm to get some real time debugging happening. 

I've noticed that no matter where i put a breakpoint in any of my php modules, it seems to return the following error.

Error: __debuginfo() must return an array (line 55 of /Users/FrancisChung/site/Test/templates/head.inc) 
This error message was shown because you are logged in as a Superuser. Error has been logged.

I was wondering if fellow Processwire users have a similar setup, and was successful in getting debugging going.

I've also read this forum post:

https://processwire.com/talk/topic/1611-yes-debugging-templates-and-core-code-works/

I'm also aware there's an issue with XDebug and Processwire:

https://github.com/ryancramerdesign/ProcessWire/issues/1316

  • Like 1
Link to comment
Share on other sites

Update : XDebug seems to work with Processwire & PHP 5.5 but not PHP 5.6 or above.

I think PHP 5.6 introduced a new magic method for __DebugInfo() and it's problematic when it tries to debug Processwire.

Not sure if Processwire objects are using var_dump().

Link to comment
Share on other sites

  • 5 months later...

I am currently still experiencing this with PW 2.7.2 on any version of PHP 5.6+

Has this not been fixed yet, is there a patch I can manually apply. I'd rather not have to downgrade my dev environments just to be able to use xdebug. Heck, XAMPP ships with 5.6 by default now.

Link to comment
Share on other sites

  • 3 weeks later...

I am currently still experiencing this with PW 2.7.2 on any version of PHP 5.6+

Has this not been fixed yet, is there a patch I can manually apply. I'd rather not have to downgrade my dev environments just to be able to use xdebug. Heck, XAMPP ships with 5.6 by default now.

I seem to recall this could fix in the next release, but don't quote me on that as my recollection is rather hazy at the moment.

Link to comment
Share on other sites

  • 7 months later...

So I've managed to get XDebug working partially with PHP7.

It seems that XDebug throws the __debugInfo must return an array error on any breakpoints where the php code is not a class definition. If I put breakpoints in any classes, debugging works fine. 

Also, I don't know whether it's a different issue but I had to set break on first line in PHPStorm to get the debugger start up properly. Perhaps there's some bootstrapping going on with this option that isn't happening elsewhere.

I've used the same config for PHP 5.5 and everything works as previously.

 

So until they fix this issue (which was allegedly fixed in Xdebug 2.4.1), best to put breakpoints only in classes.

 

P/S If anyone needs setup instructions, here's some helpful guides.

http://www.codechewing.com/library/debug-php-with-phpstorm-xdebug-mamp/

http://manovotny.com/setup-phpstorm-xdebug-mamp-debugging/

P/P/S

More info on __debugInfo

Quote

__debugInfo() 

array __debugInfo ( void )

This method is called by var_dump() when dumping an object to get the properties that should be shown. If the method isn't defined on an object, then all public, protected and private properties will be shown.

This feature was added in PHP 5.6.0.

 

Link to comment
Share on other sites

  • 2 months later...

Any luck getting xdebug and processwire working. I'm in phpstorm as well. I can successfully break anywhere before the Wire class has been instantiated. When breaking, xdebug failed silently or I get the following error.

Warning: Uncaught Error: Class 'ProcessWire\WireDebugInfo' not found in C:\dev\www\pw\vkauai\wire\core\Wire.php:1695 Stack trace: #0 C:\dev\www\pw\vkauai\wire\core\Fuel.php(91): ProcessWire\Wire->__debugInfo() #1 C:\dev\www\pw\vkauai\wire\core\ProcessWire.php(200): ProcessWire\Fuel->set('wire', Object(ProcessWire\ProcessWire), true) #2 C:\dev\www\pw\vkauai\index.php(52): ProcessWire\ProcessWire->__construct(Object(ProcessWire\Config)) #3 {main} thrown in C:\dev\www\pw\vkauai\wire\core\Wire.php on line 1695 

Fatal error: __debuginfo() must return an array in C:\dev\www\pw\vkauai\wire\core\Fuel.php on line 91 

UPDATE:

Setting a breakpoint on the Wire.php constructor returns the above error

public function __construct() {}

But great news, breakpoints in my templates are actually working. I was unaware that my template were being compiled into the cache directory - setting breakpoints on the cached versions of my template will cause xdebug to properly break.

I am using php 7.0.13 and xdebug 2.5

 

Link to comment
Share on other sites

  • 2 years later...
  • 1 year later...

I got it working by using the ProcessWire Namespace in my php files:

<?php namespace ProcessWire;

echo 'break here';
echo 'this is after the breakpoint;

I believe this way the files don't get compiled to the cache directory, which apparently causes the breakpoints to get lost

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...