daylerees / anbu

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

Anbu html outputs before any other output, including headers #32

Open nned opened 9 years ago

nned commented 9 years ago

Maybe I am doing something wrong? In my case Anbu html code is outputing before even < html > tag -- i.e before any ouput from templates. Which totally screws all session handling.

I wasted 4 hours trying to understand why auth suddenly stopped working - the answer was due to output before headers, cookies were not properly set, and new session was regenerated every page reload.

UPD: Code outputted is from view 'anbu::button'. It is echoed in anbu/src/Profiler.php @213 Maybe this hook 'executeAfterHook' is not hooked up properly?

public function executeAfterHook($request, $response) { // If the profiler is disabled... if (!$this->enabled) {

        // Exit, we don't want to log requests to the profiler.
        return;
    }

    // Execute the after hook for each module.
    $this->executeModuleAfterHooks($request, $response);

    // Store the module and return it.
    $storage = $this->storeModuleData();

    // Get content type header.
    $type = $response->headers->get('Content-Type');

    // Check for JSON in the header.
    if (strstr($type, 'text/html') && $this->display) {

        // Get the view component.
        $view = $this->app->make('view');

        // Append button to response.
       echo $view->make('anbu::button', compact('storage'));  # <============
    }
}
barryvdh commented 9 years ago

This should be fixed on dev master already.