Skip to content

Updated the helper method dd() #860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 31, 2012
Merged

Conversation

stevefrost
Copy link
Contributor

currently dd() just dies a var_dump(), I wrapped it in pre tags, so it's more readable on screen

@daylerees
Copy link
Contributor

Thanks! Marking as tested working for Taylor to consider, +1 from me :)

@CoolGoose
Copy link
Contributor

I wonder if it would be worth to also do a is_array check and use print_r in that case.

@daylerees
Copy link
Contributor

Also if it's an integer we could draw ascii hearts to represent the number.

<3 <3 <3 <3

One helper to rule them all!

@vespakoen
Copy link
Contributor

Check for the xdebug extension, when not present, hide the output and link to the installation page

@jasonlewis
Copy link
Contributor

Hang on, mine is already formatted all sexy like. Am I missing something here?

@vespakoen
Copy link
Contributor

That's because you probably have xdebug installed =) btw, the dd method should use func_get_args too, i end up using die(var_dump($when, $i, $want, $to, $check, $more, $than, $one, $variable));

@jasonlewis
Copy link
Contributor

Ah that would explain the sexiness. Then yes, everyone must have xdebug. :P

+1 for Koen's suggestion too, handy since at the moment I do something like this...

var_dump($something);
var_dump($variable);
dd($lastone);

@crynobone
Copy link
Member

wouldn't call_user_func_array('var_dump', $args) a better solution here?

@jasonlewis
Copy link
Contributor

Couldn't you put it all on the one line as well. Because I love saving space.

function dd()
{
    echo "<pre>", call_user_func_array('var_dump', func_get_args()), "</pre>";

    die;
}

@vespakoen
Copy link
Contributor

I am afraid it is not possible to pass func_get_args() in as an argument, it has to "live" in the function "dd"
hence the variable, you guys are right about call_user_func_array though!

@Kindari
Copy link
Contributor

Kindari commented Jul 21, 2012

@vespakoen not that it matters any longer, but it does work as of PHP 5.3.

5.2: http://codepad.viper-7.com/JwFQVW
5.3: http://codepad.viper-7.com/CKcK9f

Documentation: http://us3.php.net/manual/en/function.func-get-args.php#refsect1-function.func-get-args-notes

Just a friendly heads-up :)

@vespakoen
Copy link
Contributor

Thanks for the heads-up, good to know, guess I should check the changelog more often =)

@Jakobud
Copy link
Contributor

Jakobud commented Jul 24, 2012

Excellent change, but I just wanted to throw this out there: Isn't it pointless to include the echo '</pre>'; since you are killing the script immediately after that line? Might as well remove that since nothing after the var_dump() is going to get rendered anyways.

@daylerees
Copy link
Contributor

BANG, AND ITS IN

( Emma doesn't like it when I use that at home. )

daylerees added a commit that referenced this pull request Jul 31, 2012
Updated the helper method dd()
@daylerees daylerees merged commit 4b97c28 into laravel:develop Jul 31, 2012
@cisolarix
Copy link

After I install xdebug on my windows box, the output becomes sexy, all of the nasty curly braces are gone.

flap152 pushed a commit to flap152/laravel that referenced this pull request Nov 24, 2017
flap152 pushed a commit to flap152/laravel that referenced this pull request Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants