1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-01-17 21:38:14 +01:00
php-debugbar/docs/storage.md

46 lines
1.3 KiB
Markdown
Raw Normal View History

2013-08-14 11:53:33 +10:00
# Storage
DebugBar supports storing collected data for later analysis.
You'll need to set a storage handler using `setStorage()` on your `DebugBar` instance.
$debugbar->setStorage(new DebugBar\Storage\FileStorage('/path/to/dir'));
Each time `DebugBar::collect()` is called, the data will be persisted.
## Available storage
2013-09-20 15:46:52 -04:00
### File
2014-01-16 21:41:41 +00:00
It will collect data as json files under the specified directory
2013-09-20 15:46:52 -04:00
(which has to be writable).
2013-08-14 11:53:33 +10:00
$storage = new DebugBar\Storage\FileStorage($directory);
2013-09-20 15:46:52 -04:00
### Redis
Stores data inside a Redis hash. Uses [Predis](http://github.com/nrk/predis).
$storage = new DebugBar\Storage\RedisStorage($client);
### PDO
2014-01-16 21:41:41 +00:00
Stores data inside a database.
2013-09-20 15:46:52 -04:00
$storage = new DebugBar\Storage\PdoStorage($pdo);
The table name can be changed using the second argument and sql queries
can be changed using `setSqlQueries()`.
2013-08-14 11:53:33 +10:00
## Creating your own storage
You can easily create your own storage handler by implementing the
`DebugBar\Storage\StorageInterface`.
## Request ID generator
2014-01-16 21:41:41 +00:00
For each request, the debug bar will generate a unique id under which to store the
2013-08-14 11:53:33 +10:00
collected data. This is perform using a `DebugBar\RequestIdGeneratorInterface` object.
If none are defined, the debug bar will automatically use `DebugBar\RequestIdGenerator`
2014-01-16 21:41:41 +00:00
which uses the `$_SERVER` array to generate the id.