How to debug inside a CMS like Joomla!

Hi,
I have no problem to debug a php program (the php environment & xebug is set correctly) , but how to do it with a complete cms?

I have actually an error (a joomla error) that happens by the creation of the sitemap (frontend). The sitemap is created with a component and some plugins, the error happens in a plugin.

A thougt to put a break point in the correct file, but now how to debug until this break point?

Most of the joomla php file starts with something line "defined('_JEXEC') or die('=;)');" which stop the debugger anyway...

Thank for some help or hints

0
13 comments

Hello,

you cannot "run" the script directly of course. If you want to debug a content-plugin for example, you will have to set the breakpoint in the plugin-php and call the page like you would do it in the browser: index.php?option=com_content&id=12345&Itemid=678

Thomas

0
Avatar
Pierre Burri-Wittke

Hello Thomas,
you are the one that showed PhpStrorm at Joomla!Days in Hamburg! :-)

Ok, I made a starting page just with the index.php?option=com_xmap&view=html&id=1, this works.

But.. the debugger stops at the in plugin-file at "defined('_JEXEC') or die('=;)');", so I commented this line.

But now in the Console I get the folloing error:

Fatal error: Class 'JFactory' not found in .....

How can I make that the library / the classes are known?

Thanks again, Pierre

0

Hello,

exactly - that was me :-)

Why don't you use the debug listener and start a debug session in the browser? This is how i normally debug joomla back- and frontend without problems. There are addons to start / stop the xdebug sessions for firefox or you can save this as a bookmarklet to start a session:

javascript:(/** @version 0.4.1 */function() {document.cookie = "XDEBUG_SESSION=PHPSTORM; path=/;";})()

This way i never had problems debugging Joomla extensions....

Thomas

0
Avatar
Pierre Burri-Wittke

Hi,
you mean the firefox add-on "easy Xdebug" ?

I have to find out tomorrow about bookmarklet... there is steep learning curve the first time with an IDE...

Thanks a lot for you help.
Pierre

0
Avatar
Pierre Burri-Wittke

I got it now,

this article http://blog.jetbrains.com/webide/2011/02/zero-configuration-debugging-with-xdebug-and-phpstorm-2-0/
helped me to understand a few principles (debug listener & bookmarklets) and it works great.
Thank you, Thomas and nnmatveev :)

0

Thomas,

Since you are the resident expert on using PHPStorm and developing for Joomla :) , is this article correct for developing in Joomla for this IDE: http://devnet.jetbrains.net/message/5457020#5457020

I looked for your presentation on using PHPStorm and developing for Joomla but it was all in German :)  It would be awesome if there was an article somewhere, haven't found one yet, that might detail the Tips, trics and possible workflows.  Have you created one or do you know where one might be found?

Thanks,

-John

0

John,

I can help you with general debug principles. Do you still have an issue?

Thank you for feedback!

0

I think I have it down.

Time will tell :)

Thanks,

-John

0

There are addons to start / stop the xdebug sessions for firefox or you can save this as a bookmarklet to start a session:

javascript:(/** @version 0.4.1 */function() {document.cookie = "XDEBUG_SESSION=PHPSTORM; path=/;";})()

Hi,

please explain how exactly you do the above in firefox.

0

Hello,

for example:

right-click on the bookmarks toolbar in Firefox. Select Add Bookmark from the context menu. In the following mask, enter a name ("Start Debug Session") and paste the Bookmarklet-Code into the address-field. Save the Bookmark.

That's all...

There are also several tutorials on the web like this one: http://marklets.com/FAQ.aspx#firefox

Thomas

0

The tutorials at the links are about bookmarket while your desrciption is directly about bookmark. Following this last, i have got a pop when creating a new bookmark but i don't see any 'address-field' (please see the file attached).



Attachment(s):
Bookmarks.jpg
0

This javascript code should be inserted to the Location field of Firefox "new bookmark" dialog in your case.

Actually the easiest way to do it is just open Bookmarklet Generator at http://www.jetbrains.com/phpstorm/marklets/ and click Generate on the right (XDebug). You'll have different links appear below - just drag those you need (start/stop/debug) to the Bookmarks toolbar in Firefox.

0

Hello,

I have created the bookmark in firefox and a project from existing files. I have then set a break point in joomla main index.php file. But when I click on Debug button, nothing happens.

0

Please sign in to leave a comment.