2014-11-13 46 views
1

我已经安装:https://github.com/barryvdh/laravel-debugbar使用作曲家。Laravel 4和debugbar - 显示pdo查询?

我遵循安装程序,现在就完成了。

但是我如何看到我的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' => '[email protected]']); 

回答

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 
    } 
1

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