PHPackages                             manish-pareek/laravel-api-debugger - 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. [Framework](/categories/framework)
4. /
5. manish-pareek/laravel-api-debugger

ActiveLibrary[Framework](/categories/framework)

manish-pareek/laravel-api-debugger
==================================

Easily debug your JSON API.

4.0.0(5y ago)010.0k—0%MITPHPPHP &gt;=7.1

Since Jul 8Pushed 5mo agoCompare

[ Source](https://github.com/manish-pareek/laravel-api-debugger)[ Packagist](https://packagist.org/packages/manish-pareek/laravel-api-debugger)[ RSS](/packages/manish-pareek-laravel-api-debugger/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (28)Used By (0)

Laravel-API-Debugger
====================

[](#laravel-api-debugger)

[![Travis](https://camo.githubusercontent.com/93e9bdc997124001df0d8bf7f2dc91869204ec9f36382397ecdf5eddb4db9b37/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f727573742d6c616e672f727573742e737667)](https://travis-ci.org/mlanin/laravel-api-debugger)

> Easily debug your JSON API.

When you are developing JSON API sometimes you need to debug it, but if you will use `dd()` or `var_dump()` you will break the output that will affect every client that is working with your API at the moment. Debugger is made to provide you with all your debug information and not corrupt the output.

```
{
  "posts": [
    {
      "id": 1,
      "title": "Title 1",
      "body": "Body 1"
    },
    {
      "id": 2,
      "title": "Title 2",
      "body": "Body 2"
    }
  ],
  "meta": {
    "total": 2
  },
  "debug": {
    "database": {
      "total": 2,
      "items": [
        {
          "connection": "accounts",
          "query": "select * from `users` where `email` = 'john.doe@acme.com' limit 1;",
          "time": 0.38
        },
        {
          "connection": "posts",
          "query": "select * from `posts` where `author` = '1';",
          "time": 1.34
        }
      ]
    },
    "dump": [
      "foo",
      [
        1,
        2,
        "bar"
      ]
    ]
  }
}
```

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

[](#installation)

> This help is for Laravel 5.4 only. Readme for earlier versions can be found in the relevant branches of this repo.

[PHP](https://php.net) &gt;=5.5.9+ or [HHVM](http://hhvm.com) 3.3+, [Composer](https://getcomposer.org) and [Laravel](http://laravel.com) 5.4+ are required.

To get the latest version of Laravel Laravel-API-Debugger, simply add the following line to the require block of your `composer.json` file.

For PHP &gt;= 7.1:

```
"lanin/laravel-api-debugger": "^4.0"

```

For PHP &lt; 7.1:

```
"lanin/laravel-api-debugger": "^3.0"

```

You'll then need to run `composer install` or `composer update` to download it and have the autoloader updated.

Once Laravel-API-Debugger is installed, you need to register the service provider. Open up `config/app.php` and add the following to the providers key.

For Laravel 5.4

```
Lanin\Laravel\ApiDebugger\ServiceProvider::class,
```

Also you can register a Facade for easier access to the Debugger methods.

For Laravel 5.4

```
'Debugger' => Lanin\Laravel\ApiDebugger\Facade::class,
```

For Laravel 5.5 package supports [package discovery](https://laravel.com/docs/5.5/packages#package-discovery) feature.

Json response
-------------

[](#json-response)

Before extension will populate your answer it will try to distinguish if it is a json response. It will do it by validating if it is a JsonResponse instance. The best way to do it is to return `response()->json();` in your controller's method.

Also please be careful with what you return. As if your answer will not be wrapped in any kind of `data` attribute (`pages` in the example above), frontend could be damaged because of waiting the particular set of attributes but it will return extra `debug` one.

So the best way to return your responses is like this

```
$data = [
    'foo' => 'bar',
    'baz' => 1,
];

return response()->json([
    'data' => [
        'foo' => 'bar',
        'baz' => 1,
    ],
]);
```

For more info about better practices in JSON APIs you can find here

Debugging
---------

[](#debugging)

Debugger's two main tasks are to dump variables and collect anny additional info about your request.

### Var dump

[](#var-dump)

Debugger provides you with the easy way to dump any variable you want right in your JSON answer. This functionality sometimes very handy when you have to urgently debug your production environment.

```
$foo = 'foo';
$bar = [1, 2, 'bar'];

// As a helper
lad($foo, $bar);

// or as a facade
\Debugger::dump($foo, $bar);
```

You can simultaneously dump as many vars as you want and they will appear in the answer.

**Note!** Of course it it not the best way do debug your production environment, but sometimes it is the only way. So be careful with this, because everyone will see your output, but at least debug will not break your clients.

### Collecting data

[](#collecting-data)

**Note!** By default Debugger will collect data ONLY when you set `APP_DEBUG=true`. So you don't have to worry that someone will see your system data on production.

All available collections can be found in `api-debugger.php` config that you can publish and update as you wish.

#### QueriesCollection

[](#queriescollection)

This collections listens to all queries events and logs them in `connections`, `query`, `time` structure.

#### CacheCollection

[](#cachecollection)

It can show you cache hits, misses, writes and forgets.

#### ProfilingCollection

[](#profilingcollection)

It allows you to measure time taken to perform actions in your code. There are 2 ways to do it.

Automatically:

```
Debugger::profileMe('event-name', function () {
    sleep(1);
});
```

Or manually:

```
Debugger::startProfiling('event-name');
usleep(300);
Debugger::stopProfiling('event-name');
```

Also helpers are available:

```
lad_pr_start();
lad_pr_stop();
lad_pr_me();
```

### Extending

[](#extending)

You can easily add your own data collections to debug output. Just look at how it was done in the package itself and repeat for anything you want (for example HTTP requests).

Contributing
------------

[](#contributing)

Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance49

Moderate activity, may be stable

Popularity24

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 89.5% 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 ~73 days

Recently: every ~129 days

Total

26

Last Release

2131d ago

Major Versions

0.1 → 1.0.02015-11-27

0.2.3 → 2.0.02016-10-18

0.3.5 → 3.0.02017-10-16

3.0.0 → 5.1.x-dev2017-10-16

3.5.1 → 4.0.02020-07-09

PHP version history (4 changes)0.1PHP &gt;=5.4.0

0.3.0PHP &gt;=5.5.9

0.3.3PHP &gt;=5.6.0

4.0.0PHP &gt;=7.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/68919068?v=4)[manish pareek](/maintainers/manish-pareek)[@manish-pareek](https://github.com/manish-pareek)

---

Top Contributors

[![mlanin](https://avatars.githubusercontent.com/u/467159?v=4)](https://github.com/mlanin "mlanin (51 commits)")[![amcsi](https://avatars.githubusercontent.com/u/116494?v=4)](https://github.com/amcsi "amcsi (2 commits)")[![DenisJunio](https://avatars.githubusercontent.com/u/38760003?v=4)](https://github.com/DenisJunio "DenisJunio (1 commits)")[![manish-pareek](https://avatars.githubusercontent.com/u/68919068?v=4)](https://github.com/manish-pareek "manish-pareek (1 commits)")[![mannysoft](https://avatars.githubusercontent.com/u/774913?v=4)](https://github.com/mannysoft "mannysoft (1 commits)")[![MASNathan](https://avatars.githubusercontent.com/u/2139464?v=4)](https://github.com/MASNathan "MASNathan (1 commits)")

---

Tags

logjsonapiframeworklaraveldebugdumpdebuggerqueries

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/manish-pareek-laravel-api-debugger/health.svg)

```
[![Health](https://phpackages.com/badges/manish-pareek-laravel-api-debugger/health.svg)](https://phpackages.com/packages/manish-pareek-laravel-api-debugger)
```

###  Alternatives

[lanin/laravel-api-debugger

Easily debug your JSON API.

2311.8M](/packages/lanin-laravel-api-debugger)[saad/api-debugger

Easily debug your JSON API.

1170.1k](/packages/saad-api-debugger)[lanin/laravel-api-exceptions

All in one solution for exception for JSON REST APIs on Laravel and Lumen.

40102.4k](/packages/lanin-laravel-api-exceptions)[guanguans/laravel-soar

SQL optimizer and rewriter for laravel. - laravel 的 SQL 优化器和重写器。

2227.8k](/packages/guanguans-laravel-soar)[evias/nem-php

Composer Package for PHP (Laravel or Pure PHP), Wrapper to use the NEM blockchain REST API and SDK with NIS compatibility.

342.9k](/packages/evias-nem-php)

PHPackages © 2026

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