1

我已经安装:https ://github.com/barryvdh/laravel-debugbar使用作曲家。

我按照安装程序,现在完成了。

但是如何查看我的 PDO mysql 查询?我正在构建一个 RESTful api,没有任何 HTML/视图渲染。

不知道它是否有任何用途,但这是我的代码的一些示例:

    // 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']);
4

2 回答 2

1

调试栏应在启用时记录所有请求,即使不输出 HTML。您可以尝试创建 1 个简单的 HTML 页面,以便渲染调试栏。您可以单击“浏览”按钮(在右侧,关闭按钮旁边)来浏览以前的请求。你应该得到一个包含收集到的请求的列表,你可以通过 url/ip/method 进行过滤。单击该按钮将在 Debugbar 上显示该信息。

于 2014-11-14T10:34:25.777 回答
0

简单的:

    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
    }
于 2014-11-13T21:31:24.797 回答