Commit 00ac4f76 by Klimov Paul

Added a debug toolbar panel for MongoDB

parent ae392153
......@@ -7,6 +7,7 @@ Yii Framework 2 mongodb extension Change Log
- Bug #3385: Fixed "The 'connected' property is deprecated" (samdark)
- Enh #3520: Added `unlinkAll()`-method to active record to remove all records of a model relation (NmDimas, samdark, cebe)
- Enh: Gii generator for Active Record model added (klimov-paul)
- Enh: Added a debug toolbar panel for MongoDB (klimov-paul)
2.0.0-beta April 13, 2014
......
......@@ -286,3 +286,29 @@ return [
> Note: since MongoDB is schemaless, there is not much information, which generated code may base on. So generated code
is very basic and definitely requires adjustments.
Using the MongoDB DebugPanel
----------------------------
The yii2 MongoDB extensions provides a debug panel that can be integrated with the yii debug module
and shows the executed MongoDB queries.
Add the following to you application config to enable it (if you already have the debug module
enabled, it is sufficient to just add the panels configuration):
```php
// ...
'bootstrap' => ['debug'],
'modules' => [
'debug' => [
'class' => 'yii\\debug\\Module',
'panels' => [
'mongodb' => [
'class' => 'yii\\mongodb\\debug\\MongoDbPanel',
],
],
],
],
// ...
```
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\mongodb\debug;
use yii\debug\panels\DbPanel;
use yii\log\Logger;
/**
* MongoDbPanel panel that collects and displays MongoDB queries performed.
*
* @author Klimov Paul <klimov@zfort.com>
* @since 2.0
*/
class MongoDbPanel extends DbPanel
{
/**
* @inheritdoc
*/
public function getName()
{
return 'MongoDB';
}
/**
* Returns all profile logs of the current request for this panel.
* @return array
*/
public function getProfileLogs()
{
$target = $this->module->logTarget;
return $target->filterMessages($target->messages, Logger::LEVEL_PROFILE, [
'yii\mongodb\Collection::*',
'yii\mongodb\Query::*',
'yii\mongodb\Database::*',
]);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment