daylerees / anbu

Anbu profiler for the Laravel PHP Framework.
308 stars 24 forks source link

[FEATURE] Only display if in debug mode #10

Closed mikeerickson closed 10 years ago

mikeerickson commented 10 years ago

Is there any chance you could add support for displaying profiler button when in debug mode ONLY? I have hacked it together, but since this is still a fluid project (with many more updates coming) figured it would be better to have you add it to package.

daylerees commented 10 years ago

I've thought about this, and the problem is that it might encourage people to use Anbu in a production environment. I'd rather they only register its SP within a development env config file. What do you think?

barryvdh commented 10 years ago

What would be the danger of using Anbu in production as long as it's disabled?

The reason I listen to app.debug in laravel-debugbar (and what I've seen from most other profilers), is that you sometimes want to enable it at runtime (for specific IPs, admin users etc to 'hotfix' something), or because I tend to forget to remove a debug statement, which would crash when the SP isn't registered. I would think the impact should be minimal if you don't actually debug/listen to events and change the output.

MartelliEnrico commented 10 years ago

@daylerees maybe you could put a guard in the service provider, and if the env is production (or not local/testing/wathever) return without continuing, preventing the /anbu routes and everything else from appearing, even if the button is hidden.

foysalit commented 10 years ago

+1 I was going to request this but was waiting for the first beta release since dayle is already putting in so much work into this and mentioned not to submit bugfix/prs yet.

timReynolds commented 10 years ago

Another library that does this is Barryvdh\Debugbar

GrahamCampbell commented 10 years ago

:+1: for doing it like debugbar does. It has an enabled config key which by default is set to Config::get('app.debug'), so people can manually just set it to true/false if they want to.


https://github.com/barryvdh/laravel-debugbar/blob/v1.7.6/src/config/config.php#L16

manzwebdesigns commented 10 years ago

I say ditto to @GrahamCampbell and @timReynolds' comments. FWIW.

Bud

foxted commented 10 years ago

I also like the debugbar approach :)

cfreear commented 10 years ago

I know it's a bit lazy but I like to turn debug on momentarily if I encounter unexpected behaviour in production (our app is internal so this isn't too bad), having Anbu turn on at the same time would be great!

marcvdm commented 10 years ago

Maybe something like a maintenance command.

php artisan anbu:debug up/down/status

or

php artisan anbu:debug on/off/status

with status you can check if the current application is in debug mode. This way when deploying its always off and can be turned on by these commands.

timReynolds commented 10 years ago

@daylerees is your only concern that some people might turn it on in production which will affect performance and probably security? Would be good to understand your thoughts, generally people seem to like the convenience of it being linked to app.debug

daylerees commented 10 years ago

Hi guys, performance and security are my main concerns. However, it looks like the majority would be interested in having a configuration key, with a default value of app.debug. I'll make this happen in the next alpha which shouldn't be too long now.

mikeerickson commented 10 years ago

@daylerees Thanks mate!