What is the correct way to add PHP DebugBar without hacking core?

Permalink 1 user found helpful
Since 5.7 is now built with modern day PHP and uses composer etc, i was thinking adding something like php debugbar would be fairly easy to do (without editing core files) but i havent seen alot of documentation on extending core at that level.

Using PHP Debug bar as an example (http://phpdebugbar.com/) what would be the correct way to add this functionality? Is it even possible without hacking core?

 
ramonleenders replied on at Permalink Reply
ramonleenders
Just try it out. Add it to your composer.json and run composer update (or composer install). Then see the docs here:http://phpdebugbar.com/docs/. They have this code documented:

<?php
use DebugBar\StandardDebugBar;
$debugbar = new StandardDebugBar();
$debugbarRenderer = $debugbar->getJavascriptRenderer();
$debugbar["messages"]->addMessage("hello world!");
?>
<html>
    <head>
        <?php echo $debugbarRenderer->renderHead() ?>
    </head>
    <body>
        ...
        <?php echo $debugbarRenderer->render() ?>
    </body>
</html>


You can easily drop that in your header and footer of your theme. If not everything is being debugged, you could look at using some before render events in a module's on start function or something.
tolusonaike replied on at Permalink Reply
I actually did this several times.

Method 1:

When i added debugbar to concrete's composer.json, and ran composer update, it updated ALL the bundles in the concrete project too! This broke concrete itself (Got a white screen of death after doing this) maybe wild cards should not be used in the composer file for release versions? Also, isnt this technically "hacking core" will these files not be overwritten when you update concrete5.7?

Method 2:

So i used "composer require" and installed just the DebugBar and used the same code in the Docs. I got an error that DebugBar class Could not be found. Probably because it has to be injected somewhere in the view object.

I am sure its possible to extend concrete5.7 at this level but i am trying to find out the proper way to do these things so i am not "hacking core"
ramonleenders replied on at Permalink Reply
ramonleenders
What if you run composer install before your installation and try if it still works? I've done an update on composer and it ran successfully. It shouldn't break your install. Composer is there to be used, if it can't be used, it's of no use right? So try with a clean install instead of an existing install?
tolusonaike replied on at Permalink Reply
As stated above, Method 2 worked. I successfully installed debugbar. I see it inside the vendor folder.

But when i put the code in the template, I get an error telling me that DebugBar object could not be found
tolusonaike replied on at Permalink Reply
I decided to test composer update without trying to get phpdebug to work:

Fresh install of Concrete Version 5.7.4.2
Empty site

I ran composer update and get a white screen. No URL works anymore.
ramonleenders replied on at Permalink Reply
ramonleenders
I did a composer require as well, and that part worked. No update or install, not needed I guess. I'm not too familiar with the rest, but the class couldn't be found on my end either. The file actually exists and I could find it under concrete/vendor. Perhaps someone else can jump in and explain what to do.

As for your blank screen, configure concrete5 to display errors (display_errors). I'm on my iPad right now, but you can find the info right here:https://www.concrete5.org/community/forums/5-7-discussion/how-to-ove... It's the second post, at the very bottom. Put that in your application/config/concrete.php
tolusonaike replied on at Permalink Reply
Thanks for your help Ramon,

As for the composer update error, after doing as you mentioned, i see the true error:

Whoops \ Exception \ ErrorException (E_ERROR)
HELP
Class 'TrueBV\Punycode' not found
......
    public function __construct($data = null)
    {
        $this->punycode = new Punycode('UTF-8');
        parent::__construct($data);
    }
......


Looks like some bundle class was added/removed/changed in some newer version.
MrKDilkington replied on at Permalink Reply
MrKDilkington
I have never heard of PHP Debug Bar until reading this thread.

I looked over some of the documentation and it looks very interesting.
MrKDilkington replied on at Permalink Best Answer Reply 1 Attachment
MrKDilkington
Good news, developers Mnkras and Korvin very generously made a PHP Debug Bar package for everyone to use.

https://github.com/Mnkras/php_debugbar...

I am also including the package with the dependencies already installed as an attachment. It has everything it needs to be installed.

Once installed, the toolbar should be available to use.

I believe it needs further customization to make the most of what it can do.
tolusonaike replied on at Permalink Reply
Nice! It works. Would it be possible to display controller variables in the debug bar?
MrKDilkington replied on at Permalink Reply
MrKDilkington
@tolusonaike

I am not sure what type of customization could be done.

Also, it currently does not get POST/GET data from block and dashboard single page forms. These forms use AJAX to transfer data.

On the PHP Debug Bar website it lists that it handles AJAX requests. We all need to brainstorm to figure out how to enable AJAX request collection.
http://phpdebugbar.com/docs/ajax-and-stack.html#ajax-and-stacked-da...
jakobfuchs replied on at Permalink Reply
jakobfuchs
Here's another nice debugging tool for Concrete5, that I found recently:

https://github.com/dorian-marchal/concrete5-kint-debug...
MrKDilkington replied on at Permalink Reply
MrKDilkington
@jakobfuchs

Nice find, have you tried it yet?
ramonleenders replied on at Permalink Reply
ramonleenders
Seems to be more or less of an extended xdebug functionality. This will only show if you use "their" dump version (d() instead of var_dump()). It's not a debug BAR like the OP shows. You have debug bars for other frameworks too, like laravel:https://cloud.githubusercontent.com/assets/973269/4270452/740c8c8c-3...

But this seems to be a sort of replacement for calling var_dump, from what I gather.
JohntheFish replied on at Permalink Reply
JohntheFish
An addon for Kint is currently in the PRB.
tolusonaike replied on at Permalink Reply 1 Attachment
All these discussions made me try out other options. I was able to get debugging working through phpstorm and it is mighty nice. As close to the .Net Visual Studio experience as i have gotten in PHP. Screenshot attached
WebcentricLtd replied on at Permalink Reply
+1 for phpstorm. I wouldn't be without it now.
WebcentricLtd replied on at Permalink Reply
+1 for phpstorm. I wouldn't be without it now.