Laravel 4 and debugbar - show pdo queries?

594 views Asked by At

I have installed: https://github.com/barryvdh/laravel-debugbar using composer.

I followed install procedures, and now done.

But how do I see my PDO mysql queries? I am building a RESTful api, without any HTML/view rendering.

Don't know if it is for any use, but heres some example of my code:

    // the controller
    public function feed($exclude = null) {

        $feed = $this->item->feed()->with('attributes', 'images', 'user');

        if($exclude)
            $feed->whereNotIn('id', explode(',', $exclude));
        return ['items' => $this->itemTransformer->transformCollection($feed->get()->toArray())]; // woud like to debug this query
    }

    // the router
    Route::get('items/feed/{exclude?}', ['protected' => true, 'uses' => 'ItemsController@feed']);
2

There are 2 answers

0
FooBar On

Easy:

    public function feed($exclude = null) {

        $feed = $this->item->feed()->with('attributes', 'images', 'user');

        if($exclude)
            $feed->whereNotIn('id', explode(',', $exclude));

        $items = ['items' => $this->itemTransformer->transformCollection($feed->get()->toArray())];

        echo json_encode($items); // echo instead of return. Will trigger HTML to render and
    }
0
Barryvdh On

The Debugbar should log all requests when enabled, even when not outputting HTML. You could try to create 1 simple HTML page so that the Debugbar gets rendered. You can click the Browse button (on the right, next to the close button) to browse previous requests. You should get a list with collected requests, which you can filter by url/ip/method. Clicking that will show that information on the Debugbar.