Skip to content
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

[9.x] Adds source file to dd function output 💅🏻 #44211

Merged
merged 12 commits into from
Sep 21, 2022
Merged

Conversation

nunomaduro
Copy link
Member

@nunomaduro nunomaduro commented Sep 19, 2022

This pull request improves the dd output by adding the source file/line to the dd output.

It's very common to use dd while developing Laravel applications and forget about the original place where the dd was left. So, this pull request solves that, by adding a very minimal gray text with the source file/line:

Screenshot 2022-09-19 at 18 03 47

This improvement also works on the HTTP layer, and any dd call on the browser will look like so:

Screenshot 2022-09-20 at 12 34 56

In addition, if the app.editor configuration is defined, the source link will be clickable:

Screenshot 2022-09-20 at 12 35 56

@nunomaduro nunomaduro changed the title [9.x] Adds source file / line to dd 🧙🏻‍♀️ [9.x] Adds source file to dd function output 💅🏻 Sep 19, 2022
@foremtehan
Copy link
Contributor

This is awesome!

@nicolas-grekas
Copy link
Contributor

FYI, Symfony natively supports this since symfony/symfony#31446

There are a few differences of course: we decided to go with a ^ at the beginning of the line instead of a full path. This saves space on the screen when using many dump(). On hover, the ^ displays the file+line info and on ctrl+click the IDE opens at that location.

You might want to have look at the code there and maybe reuse some of the infrastructure.

Peek 10-09-2019 15-05

@nunomaduro nunomaduro marked this pull request as ready for review September 20, 2022 16:16
@EricPaulson
Copy link

EricPaulson commented Sep 21, 2022

This looks great! Just a couple of questions:

  1. Is there a way to suppress the extra output for cases where we don't want or need it?
  2. Are there any concerns with exposing internal application details to the public in the case where a stray dd() is accidentally left behind?
  3. Does this also update dump()?

@taylorotwell taylorotwell merged commit 3f06333 into 9.x Sep 21, 2022
@taylorotwell taylorotwell deleted the feat/dd-source branch September 21, 2022 16:06
@Pinnokkio
Copy link

How to enable this feature? I've update to Laravel 9.31.0 but I don't see anything behind my dd. Thanks.

@marcusmoore
Copy link
Contributor

@Pinnokkio it isn't tagged yet but I would guess it comes out in next Tuesday's release.

@decadence
Copy link
Contributor

decadence commented Sep 30, 2022

Have Laravel 9.33.0 and still this doesn't work for some reason

@nunomaduro
Copy link
Member Author

Can you share your "composer.lock" file?

@decadence
Copy link
Contributor

@nunomaduro
composer.txt

@nunomaduro
Copy link
Member Author

I've just used that composer.lock in a fresh Laravel, and it's working for me as expected.

@decadence
Copy link
Contributor

I deleted vendor folder and run composer install, still not working 🤷‍♂️
Ok seems like some problem due to old project.

@Pinnokkio
Copy link

Same for me, still not working in 9.33.

@nunomaduro
Copy link
Member Author

@decadence @Pinnokkio What operating system are you using?

@decadence
Copy link
Contributor

decadence commented Sep 30, 2022

Windows 10 and Linux, but I tried only on Windows at this time

@putheakhem
Copy link

I have the same problem on Window 10 when update from Laravel 9.25.1 to 9.33.0

@Pinnokkio
Copy link

@decadence @Pinnokkio What operating system are you using?

Windows 10, 21H2

@jrd-lewis
Copy link
Contributor

I'm not seeing any difference either on Windows 11, 22H2.

@decadence
Copy link
Contributor

decadence commented Oct 4, 2022

Windows 10 and Linux, but I tried only on Windows at this time

@nunomaduro Works on Linux with the same project. Seems like some problem on Windows.

image

@nunomaduro
Copy link
Member Author

Fixed: #44451.

@decadence
Copy link
Contributor

Great 💪

@Pinnokkio
Copy link

It now works, but does anyone know why it has a different font?
image

@jrd-lewis
Copy link
Contributor

It now works, but does anyone know why it has a different font? image

Maybe because of #44331?

@datlechin
Copy link
Contributor

datlechin commented Oct 8, 2022

@nunomaduro can't open array?

image

@dennisprudlo
Copy link
Contributor

@datlechin How deeply nested is this model? After some levels it's not possible to disclose them anymore.

@datlechin
Copy link
Contributor

@dennisprudlo it’s Collection

Post::all();

@lparede
Copy link

lparede commented Oct 18, 2022

@nunomaduro
Laravel 9.36 and still no information about the location of the dd(). composer.lock is updated.

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.