daylerees / anbu

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

Conflict with Asset Pipeline #4

Closed JasonSuave closed 10 years ago

JasonSuave commented 10 years ago

When serving assets through CodeSleeve/asset-pipeline, the profiler also runs for each asset served. Hence the HTML for the Anbu link is prepended to each of those files causing them to be unusable.

screen shot 2014-09-08 at 14 47 27

In the Profiler in the afterHook method changing this check

if (!strstr($type, 'json')) {

to

if (strstr($type, 'text/html')) {

resolved the issue for me. Mind you that the profiler will still run for each asset served, so your page might load slowly. Since this is a work in progress and @daylerees requested it, I havent created a pull request for this.

daylerees commented 10 years ago

Thanks man, I'll just have to hope people are using the view component or setting correct headers.

As for the profiler still loading, it's really difficult to decide whether or not to load the profiler early. The only thing I could think of doing is having an array of route prefixes that will disable registration of the profiler. Although the profiler isn't intended for use in production, so it shouldn't be too much of a hassle.

daylerees commented 10 years ago

Hey @JasonSuave I've changed the mime type detection to what you've suggested. It should work fine. I've also provided route filter anbu.hide for disabling the button, this should add for some additional flexibility.

Thanks for the descriptive PR dude!

JasonSuave commented 10 years ago

No worries @daylerees. Great to finally be able to contribute to something. :smile: