FirePHP plugin

FirePHP plugin

by Frank Ralf -
Number of replies: 30
Hi,

This is a very first stab at a plugin that provides FirePHP integration for Moodle. It follows a similar approach as the one suggested in MDL-16371 but instead of patching core Moodle code it follows a modular plugin approach.

That way, it can provide some basic access control and configurabiltiy.

Basically, the plugin does the following:

1) integrating the FirePHP Core Library from http://www.firephp.org
2) dumping the content of the four global Moodle variables ($CFG, $SITE, $USER and $COURSE) to the FirePHP console, where they can be inspected using FirePHP's powerful Variable Viewer (see screenshot)
3) redirecting error and exception handling to Firebug

For more information see:
http://www.firephp.org/HQ/Learn.htm
http://www.firephp.org/HQ/Use.htm

The plugin still leaves much to be desired:

* better configurability (at the moment the plugin can only be globally activated/deactivated site wide)
* better integration with build in Moodle debugging features
* full use of language strings for localisation

Any comments and suggestions for improvement are welcome!

Kind regards,
Frank

You can download the code under www.nakohdo.de/downloads/firephp.zip
Attachment FirePHP_Plugin.gif
Average of ratings: Useful (1)
In reply to Frank Ralf

Re: FirePHP plugin

by Nadav Kavalerchik -
Picture of Core developers Picture of Plugin developers Picture of Testers Picture of Translators
great idea to have it as a block plugin !

thou, i had a little issue with it.

i was getting FATAL uncaught exception... error
so i had to remark line 2664 inside lib/weblib.php
//ob_end_clean();

now it works great and it even helped my get some info i was needing
from the $COURSE global var. (thanks)
In reply to Nadav Kavalerchik

Re: FirePHP plugin

by Nadav Kavalerchik -
Picture of Core developers Picture of Plugin developers Picture of Testers Picture of Translators
actually, a better hack was to change lines 2661 >> 2665 to
ob_start("header");
include($CFG->header);
$output = ob_get_contents();
ob_end_clean();
ob_start();

so it will not break Moodle's visual theme display
if i disable the block.
Average of ratings: Useful (1)
In reply to Nadav Kavalerchik

Re: FirePHP plugin

by Frank Ralf -
Thanks for trying the plugin and for the feedback and bug report!

Actually, it should be the responsibility of the plugin not to produce errors wink Will try to amend that.

Cheers,
Frank
In reply to Frank Ralf

Re: FirePHP plugin

by Frank Ralf -
Everything works fine on my local development machine (Win 2000, XAMPP), but I could reproduce the error on a remote Linux machine, so I suppose it has something to do with the server or PHP settings. Thanks again for the hint!

In reply to Frank Ralf

Re: FirePHP plugin

by Frank Ralf -
Only tying up some loose ends...

Here's a short instruction on installing the plugin (taken from http://dev.moodle.org/mod/forum/discuss.php?d=363&parent=805):

For properly installing and enabling the plugin do the following:

1) Click on "Notifications" in the Site Admin menu
2) Enable the plugin under Modules > Blocks > FirePHP
3) The plugin is a block, so you have to turn Editing on and add the FirePHP block to a course. The block only shows whether FirePHP is activated or not.
4) For security reasons the block will only be active for users with administrator rights.

There are still some problems regarding output buffering. So if you got an error message you might try setting output_buffering = On in the php.ini file (note: for XAMPP this file lives in \apache\bin\php.ini). See also Installing Moodle/Creating custom php.ini files.

And here's the discussion about that issue from the FirePHP forum:

"FirePHP on Frameworks which makes use of ob_start()"
http://n2.nabble.com/FirePHP-on-Frameworks-which-makes-use-of-ob_start%28%29-tp2510006p2510006.html

Average of ratings: Useful (1)
In reply to Frank Ralf

Re: FirePHP plugin

by Pedro Parreira -
Hi. Sorry, but I can't make it into step 3.
How do you add the FirePHP block into a course? Is it an activity or Resource?
Thanks.
In reply to Pedro Parreira

Re: FirePHP plugin

by Frank Ralf -
Well, it's a block and therefore you should have copied the code to the \block folder. (That should have been step 0.)

Then the FirePHP block should show up in the list of blocks in the "Add Block" block when you have turned editing on.

hth
Frank

In reply to Frank Ralf

Re: FirePHP plugin

by Pedro Parreira -
Ok, I got it.
But now an error appears when I try to add the block:


Fatal error: Exception
thrown without a stack
frame in Unknown on
line 0

This is also stopping me to add more blocks to my moodle pages because it replaces the add block dropdown list. I have my debugging options set to NORMAL. If I take the debugging options off the add block just disappears along with the error message.
In reply to Pedro Parreira

Re: FirePHP plugin

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I hit this recently, and it is what happen when another exception is thrown when one is in the middle of being processed.
Average of ratings: Useful (2)
In reply to Pedro Parreira

Re: FirePHP plugin

by Frank Ralf -
Hi Pedro,

Thanks for testing the plugin and your feedback. I could reproduce this error on my new installation of Moodle 2.0 dev (Build: 20090423) (2009041700). Which version do you use? Will try to find the bug.

Cheers,
Frank
In reply to Frank Ralf

Re: FirePHP plugin

by Markus Schmidt -
Hi Frank,

I recently very gald of finding the FirePHP-Plugin for moodle, because I already tried to get FirePHP working by editing the moodle php code but it didn't work. (I'm a student of software engineering and woking on my term paper now. For that I need to modify the assingment module of my moodle installation.)
Now I moved the FirePHP-code to the folder \blocks and turned it on (as mentioned in the above). But as I added the block to my curse I got the same error than Pedro did.

Fatal error: Exception thrown without a stack frame in Unknown on line 0

And nothing happens now in the Firebug console window when I do anything. Is there a fix now?

Kind regards, Markus
In reply to Markus Schmidt

Re: FirePHP plugin

by Frank Ralf -
Hi Markus,

Sorry for my late reply. Please do the following to get the plugin working:

1) Download the latest version of the FirePHP server library (FirePHPCore 0.3.2 ) from http://www.firephp.org and copy the "FirePHPCore" folder in the firephp block's folder (thereby overwriting the old versions).

2) You probably will still get an error message like the one in the screenshot which already hints at the problem. Try activating output buffering in your servers php.ini file as recommended by setting "output_buffering = ON".

hth
Frank
Attachment FirePHP error message.png
In reply to Frank Ralf

Re: FirePHP plugin

by Frank Ralf -
I have created a first version of this plugin which works with Moodle 2.0 (see screenshot) and updated the FirePHP library for the 1.9 version. Both versions can be downloaded from the following URLs:

www.nakohdo.de/downloads/block_firephp19.zip
www.nakohdo.de/downloads/block_firephp20.zip

Attachment Moodle 2.0 FirePHP block 256.png
In reply to Frank Ralf

Re: FirePHP plugin

by Frank Ralf -
This is a slightly updated version for Moodle 2.0. Besides some more verbose text in the block itself it also shows the new global variable $PAGE.
Average of ratings: Useful (1)
In reply to Frank Ralf

Re: FirePHP plugin

by Nick Freear -

Hi Frank,

This is excellent work, thanks. I'll be giving it a try, particularly as I work on Javascript stuff like SimpleSpeak. A few requests:

  • Can you put the code up on Github, so the community can help out, and for easier tracking of fixes? See Git for contrib in the Wiki.
  • Can you add the plugin to the database please?

Thanks again. Best wishes,

Nick

In reply to Nick Freear

Re: FirePHP plugin

by Frank Ralf -
Hi Nick,

Thanks for the feedback. Seems like I cannot avoid Git any longer wink

Frank
In reply to Frank Ralf

Re: FirePHP plugin

by Frank Ralf -
In reply to Frank Ralf

Re: FirePHP plugin

by Frank Ralf -
Now also on GitHub at https://github.com/nakohdo/moodle-block_firephp

(but still a work in progress)
In reply to Frank Ralf

FirePHP block in Moodle Plugins Directory

by Frank Ralf -
It's been quite a long time but I finally registered the plugin in the Moodle plugins Directory: https://moodle.org/plugins/view.php?plugin=block_firephp - still waiting for approval, so stay tuned wink
Average of ratings: Useful (1)
In reply to Frank Ralf

Re: FirePHP block in Moodle Plugins Directory

by Luis de Vasconcelos -
Picture of Particularly helpful Moodlers

I get a "you do not have permission to view this plugin" error on that page. I presume it's because it's still waiting for approval?

In reply to Frank Ralf

Re: FirePHP plugin

by Bob Puffer -

Tried an install on 2.03 (20110518) and got the following error.  I get it with the "local" version posted at the end of this thread also:

In reply to Bob Puffer

Re: FirePHP plugin

by Frank Ralf -
Hi Bob,

Thanks for the feedback. Will look into this asap.

Cheers,
Frank
In reply to Frank Ralf

Re: FirePHP plugin

by Frank Ralf -
Hi Bob,

I cannot reproduce the error. The block works ok after updating my Moodle to 2.03+ and also after re-installing the block. Have you checked whether all your Moodle core files are intact?

Cheers,
Frank
In reply to Frank Ralf

Re: FirePHP plugin

by Ângelo Rigo -
Hi
I have
output_buffering no value no value
output_handler no value no value

For output_buffering the values must be ON?
And for output_handler wich values must be set? ON?

Thank´s in advance

In reply to Frank Ralf

Re: FirePHP plugin

by Paul Nicholls -

Thanks for this - it's really nifty to be able to have the core variables available in Firebug when developing smile

In reply to Frank Ralf

Re: FirePHP plugin

by Mark Johnson -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Frank,

I've made a slightly modified version of your block packaged as a local plugin, the idea being that it loads FirePHP in the lib.php, and the functions are then available for use in your code. At the moment, I've set it to use static calls (e.g. FB::info()) so save having to do "global $firebug;" in functions.

The disadvantages are that you can't automatically log $COURSE since lib.php is executed before it's set up, and you can't (as far as I can tell) enable error and exception handling.