laravel / ideas

Issues board used for Laravel internals discussions.
938 stars 28 forks source link

Ignore calls to dd(), ddd() dump() if app.debug is false. #2476

Closed warrickbayman closed 3 years ago

warrickbayman commented 3 years ago

We recently had an issue where a stray "dd()" was missed in a project which ended up in production. Needless to say we've updated our tests so we don't end up with that again, but thought it might be useful if calls the dd() and ddd() functions didn't actually do anything if config('app.debug') is false.

mfn commented 3 years ago

Firm "no" from my side. Human errors happen, but:

I equally had the use case where I needed to debug a very strange and locally unproducible case in production and, different function / different framework, lo' and behold => it was bound to such a debug settings unbeknownst to developers and it simply would not work, causing more confusion than necessary.

Also it might not be desirable to set the whole application into debug mode just because you want to quickly test something on a single route.

Changes this for well known and widely used (!) helper functions is a big no-no from my side thus. This is 180 degree against POLA [1].

If you think you or your team can't get hold of this otherwise, introduce separate helper functions which work like this.

My 2c 😄

[1] https://en.wikipedia.org/wiki/Principle_of_least_astonishment

lk77 commented 3 years ago

Same thing, a lot of times, i had to use a dd in production, to test something odd.

warrickbayman commented 3 years ago

@mfn, @lk77 okay, agreed. Was something we discussed briefly and seemed like an interesting idea at the time. Thanks.