PHPackages                             michaeljennings/snapshot - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. michaeljennings/snapshot

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

michaeljennings/snapshot
========================

A PHP package that takes a snapshot of your application and allows you to retrieve it later to help with debugging.

v0.3.9(5y ago)78.3k↓50%5MITPHPPHP &gt;=5.4.0

Since May 3Pushed 5y ago4 watchersCompare

[ Source](https://github.com/michaeljennings/snapshot)[ Packagist](https://packagist.org/packages/michaeljennings/snapshot)[ RSS](/packages/michaeljennings-snapshot/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (18)Used By (0)

Snapshot [![Latest Stable Version](https://camo.githubusercontent.com/b528c2b1210d88fa3d2db4bfcca82c17726b741f7969fa2f5b7f5cf3c40040a6/68747470733a2f2f706f7365722e707567782e6f72672f6d69636861656c6a656e6e696e67732f736e617073686f742f762f737461626c65)](https://packagist.org/packages/michaeljennings/snapshot) [![License](https://camo.githubusercontent.com/6f324c7070054e95e116e41ea2c039806ab56bfcaa378beb1abf62f0f0e9c771/68747470733a2f2f706f7365722e707567782e6f72672f6d69636861656c6a656e6e696e67732f736e617073686f742f6c6963656e7365)](https://packagist.org/packages/michaeljennings/snapshot)
============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#snapshot--)

A PHP package that stores a [whoops-like](https://github.com/filp/whoops) snapshot of your application and allows you to retrieve it later to help with debugging.

The package also comes with Slack integration so you can receive notifications whenever a snapshot is captured.

- [Planned Features](#planned-features)
- [Installation](#installation)
- [Laravel Integration](#laravel-integration)
    - [Laravel 4 Integration](#laravel-4-integration)
- [Usage](#usage)
    - [Taking a Snapshot](#taking-a-snapshot)
    - [Rendering a Snapshot](#rendering-a-snapshot)
    - [Finding a Snapshot](#finding-a-snapshot)
- [Slack Integration](#slack-integration)
    - [Customising the Message](#customising-the-message)
- [Adding Event Listeners](#adding-event-listeners)

Planned Features
----------------

[](#planned-features)

- File Store
- More views to choose from

Installation
------------

[](#installation)

This package requires PHP 5.4+ and includes laravel support.

To install through composer you can either use `composer require michaeljennings/snapshot` or include the package in your `composer.json`.

```
"michaeljennings/snapshot": "0.3.*"
```

Then run either `composer install` or `composer update` to download the package.

Laravel Integration
-------------------

[](#laravel-integration)

To use the package with Laravel 5 add the snapshot service provider to the list of service providers in `config/app.php`.

```
'providers' => array(

  'Michaeljennings\Snapshot\SnapshotServiceProvider'

);
```

Then add the `Snapshot` facade to the aliases array.

```
'aliases' => array(

  'Snapshot' => 'Michaeljennings\Snapshot\Facades\Snapshot',

);
```

Then use `php artisan vendor:publish` to publish the config and database migrations.

The package comes with database migrations if you want to use a database store. To run the migrations use `php artisan migrate` to set up the snapshot database tables.

To use the package you can either use the `Snapshot` facade or if you prefer using dependency injection snapshot is bound to the IOC container by its interface.

```
Snapshot::capture();

public function __construct(Michaeljennings\Snapshot\Contracts\Snapshot $snapshot)
{
    $this->snapshot = $snapshot;
}
```

### Laravel 4 Integration

[](#laravel-4-integration)

To use the package with Laravel 4 add the snapshot service provider to the list of service providers in `app/config/app.php`.

```
'providers' => array(

  'Michaeljennings\Snapshot\Laravel4ServiceProvider'

);
```

Then add the `Snapshot` facade to the aliases array.

```
'aliases' => array(

  'Snapshot' => 'Michaeljennings\Snapshot\Facades\Snapshot',

);
```

Then use `php artisan config:publish --path=vendor/michaeljennings/snapshot/config michaeljennings/snapshot` to publish the config.

The package comes with database migrations if you want to use a database store. To run the migrations use `php artisan migrate --package="michaeljennings/snapshot" --path=vendor/michaeljennings/snapshot/database/migrations` to set up the snapshot database tables.

To use the package you can either use the `Snapshot` facade or if you prefer using dependency injection snapshot is bound to the IOC container by its interface.

```
Snapshot::capture();

public function __construct(Michaeljennings\Snapshot\Contracts\Snapshot $snapshot)
{
    $this->snapshot = $snapshot;
}
```

Usage
-----

[](#usage)

To get started we first need to instantiate the snapshot class.

If you are using the laravel integration this is done for you when you register the service provider.

```
// Require the composer autoload
require "vendor/autoload.php";

// Get the package config
$config = require "path/to/config/snapshot.php";

// Instantiate the dependencies
$store = new $config['store']['class']($config);
$renderer = new $config['renderer'];
$dispatcher = new \Michaeljennings\Snapshot\Dispatcher(new \League\Event\Emitter());

// Create the snapshot class
$snapshot = new Snapshot($store, $renderer, $dispatcher, $config);
```

### Taking a Snapshot

[](#taking-a-snapshot)

To take a snapshot of your application use the `capture` method.

```
$snapshot = new Snapshot($store, $renderer, $dispatcher, $config);

$snapshot->capture();
```

This will store all of the debug stack trace and any server, post, get, file, cookie, session and environment variables.

If you want to store any additional data, i.e. the current user, you can pass an array of data to the `capture` method.

```
$snapshot->capture(['user_id' => 1]);
```

If you are specifically capturing an exception you can use the `captureException` method. The benefit of this method is you can override the exception message and code by passing them in. You can still store any additional data by passing it as the 4th parameter.

```
$snapshot->captureException($exception);

$snapshot->captureException($exception, 500, 'Internal Server Error', ['user_id' => 1]);
```

### Rendering a Snapshot

[](#rendering-a-snapshot)

To render a snapshot use the `render` method, this takes one parameter which is the id of the snapshot.

```
$snapshot->render(1);
```

### Finding a Snapshot

[](#finding-a-snapshot)

Alternatively if you want to choose how to render the snapshot yourself you can get the snapshot by its id using the `find` method.

```
$snapshot->find(1);
```

Slack Integration
-----------------

[](#slack-integration)

Snapshot also comes with Slack support through the excellent [mankz/slack](https://github.com/maknz/slack/) package.

In your config file just enable slack integration, and then add in your [incoming webhook endpoint](https://my.slack.com/services/new/incoming-webhook), channel, and username and you shall start receiving slack messages whenever a snapshot is captured.

This is very useful for catching errors before they are reported.

### Customising the Message

[](#customising-the-message)

By default the message will be `#{snapshot-id} A new snapshot has been captured`.

If you want to customise this message then you can extend the `Michaeljennings\Snapshot\Listeners\SendToSlack.php` event listener and override the `getMessage` method.

Then you simply need to update the listener subscribed in the snapshot config to the `Michaeljennings\Snapshot\Events\SnapshotCaptured` event to your new listener.

Adding Event Listeners
----------------------

[](#adding-event-listeners)

It is possible that you want something to happen every time a snapshot is captured. An example of this is how we send a message to slack whenever a snapshot is captured.

To do this we add in event listeners. There are two ways we can go about this, either you can subscribe you listeners in the `listeners` array in the config, or you can call the `addListener` method on the slack class.

To add one into the config set the key as the event you are subscribing to, and the value as an array of listeners.

```
'listeners' => [

    'Michaeljennings\Snapshot\Events\SnapshotCaptured' => [
        'Michaeljennings\Snapshot\Listeners\SendToSlack',
        'MyCustomListener'
    ]

]
```

To subscribe a listener using the `addListener` method pass the event name you are subscribing to as the first parameter, and then either a class name or a closure to use as a listener.

```
$snapshot->addListener('Michaeljennings\Snapshot\Events\SnapshotCaptured', 'Michaeljennings\Snapshot\Listeners\SendToSlack');

$snapshot->addListener('Michaeljennings\Snapshot\Events\SnapshotCaptured', function($event) {
    // Handle event
});
```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~124 days

Recently: every ~383 days

Total

17

Last Release

2039d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/df807d0371b1b265ea1becedfa4001428f278e7632c6d175e2afb2921f5788a3?d=identicon)[michaeljennings](/maintainers/michaeljennings)

---

Top Contributors

[![michaeljennings](https://avatars.githubusercontent.com/u/5189701?v=4)](https://github.com/michaeljennings "michaeljennings (119 commits)")[![DevKingDigital](https://avatars.githubusercontent.com/u/13821111?v=4)](https://github.com/DevKingDigital "DevKingDigital (1 commits)")[![georgehanson](https://avatars.githubusercontent.com/u/23167178?v=4)](https://github.com/georgehanson "georgehanson (1 commits)")

---

Tags

laravelsnapshotdebugging

### Embed Badge

![Health badge](/badges/michaeljennings-snapshot/health.svg)

```
[![Health](https://phpackages.com/badges/michaeljennings-snapshot/health.svg)](https://phpackages.com/packages/michaeljennings-snapshot)
```

###  Alternatives

[laracraft-tech/laravel-xhprof

Easy XHProf setup to profile your laravel application!

235321.4k](/packages/laracraft-tech-laravel-xhprof)[bavix/laravel-xhprof

Quick profiling of your code for Laravel

22156.6k](/packages/bavix-laravel-xhprof)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
