Assist with a helper

Permalink
Being a php, then fairly long time ColdFusion programmer, and now finding myself back in PHP, I really liked the cfdump function in cf. This fellow:
http://dbug.ospinto.com/
has written the equivalent in php, and I've pasted his code into a file in /mysite/helpers/dbug.php, and can include it in a block's view.php, and call it like "new dBug($somevar);". I'd like to use the Loader::Helper, but the script echoes instead of returning a string, and I haven't been quite able to sus it out to get to work. I continue to get a "Object of class dbugHelper could not be converted to string" error. It is a nifty dump, especially when trying to learn what tools are available in things like $controller etc.
If anyone had the time to outline how to get that to work properly as a helper, I'd be very thankful.

macgillivary
 
Remo replied on at Permalink Reply
Remo
print_r worked fine for me. I have to admit dBug looks better though!

Haven't build a helper function, can't help you with that yet.
andrew replied on at Permalink Reply
andrew
Would you mind attaching your helper to a post in this thread? I imagine it's just a couple little syntax tweaks that need to be made.
macgillivary replied on at Permalink Reply 1 Attachment
macgillivary
I know it has to to with the constructor's call to initJSandCSS which appears to echo directly.

Actually, looking at it again today with a clear head I think creating a private var returnstring which gets built up instead of echoing from each function might be the way to go. Then create a public function which simply returns that returnstring. I've got some time - perhaps I'll give that a go.

This is not my creation. It comes from "Kwaku Otchere".

Attached as txt as forum didn't like the .php extension.
andrew replied on at Permalink Reply
andrew
I loaded it up and output an object like this, and it seemed to work.

First, put the dbug.php file in your local helpers/ directory. Then, call it like this:

<?php
$dbh = Loader::helper('dbug');
// example object to output
$c = Page::getByID(1, 'RECENT');
$dbh->dbug($c);
macgillivary replied on at Permalink Reply
macgillivary
I put this in a view.php of my block, and also in the default.php file in the theme as a footer. I get a null with the "RECENT" but with the var I was after it works well.

I think I may have just had it in the wrong place previously - in a function in the controller perhaps.