Welcome Guest, Not a member yet? Register   Sign In
Something like laravel "dd" function
#1

I miss something like "dd" function in laravel to print the object's tree and vars.
Reply
#2

What is wrong with print_r and var_dump ?

http://php.net/manual/en/function.print-r.php
http://php.net/manual/en/function.var-dump.php

If it is the formatting on screen output try viewing the page source, much cleaner.
Reply
#3

I'm sorry, but print_r and var_dump are very simples, in large objects are very tedious debug. Please see that link http://laraveldaily.com/echoing-dd-vs-va...s-print_r/

I'm codeigniter fanatic but we should recognize the good work in another frameworks.

Regards.
Reply
#4

That post seems to be saying that dd is a PITA.

I admit that when debugging very large arrays it is a pain to decipher the content sometimes. But I just do not understand the need for dd at all. I suppose it might be handy in some contexts. It reminds me of exploring objects in a browser console, which I always find a pain. Probably because I do not do it enough.

There is no equivalent of DD in CI. Perhaps you could write one. It does not seem to be a particularly complex function, although I bet it gets complicated when you start taking into account edge cases.

Personally, if you are analysing an array of substantial size to debug something, I would always break code down into smaller chunks which are more manageable.

Quote:we should recognize the good work in another frameworks.

I totally agree with you on this. But I am still failing to see the benefit of dd

https://laracasts.com/discuss/channels/g...-of-shitty
Reply
#5

If you need something anyway, you may try https://github.com/CesiumComputer/print_d
Reply
#6

Or the old CI Favorite as a helper method:

PHP Code:
/**
 * ------------------------------------------------------------------------
 *
 * dDebug Helper
 *
 * Outputs the given variable(s) with formatting and location
 *
 * @access    public
 * @param    mixed    - variables to be output
 */
if ( ! function_exists('dDebug'))
{
    function 
dDebug()
    {
        list(
$callee) = debug_backtrace();

        
$args func_get_args();

        
$total_args func_num_args();

        echo 
'<div><fieldset style="background: #fefefe !important; border:1px red solid; padding:15px">';
        echo 
'<legend style="background:blue; color:white; padding:5px;">'.$callee['file'].' @line: '.$callee['line'].'</legend><pre><code>';

        
$i 0;

        foreach (
$args as $arg)
        {
            echo 
'<strong>Debug #' . ++$i ' of ' $total_args '</strong>: ' '<br>';

            
var_dump($arg);
        }

        echo 
"</code></pre></fieldset><div><br>";
    }

What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#7

If you like the output like dd, you can use http://symfony.com/doc/current/component...umper.html with Composer.
Reply
#8

(12-10-2016, 03:38 AM)CodeIgnitedX Wrote: I miss something like "dd" function in laravel to print the object's tree and vars.

It's not been maintained since 2007, but I use this little class file

dBug

Cool
Reply
#9

I use FirePHP. Gives me all the debugging data I need, and doesn't stop execution like dd does.
Reply
#10

Try this:

https://forum.codeigniter.com/thread-65568.html
Reply




Theme © iAndrew 2016 - Forum software by © MyBB