PHPackages                             spatie/laravel-blade-comments - 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. [Templating &amp; Views](/categories/templating)
4. /
5. spatie/laravel-blade-comments

ActiveLibrary[Templating &amp; Views](/categories/templating)

spatie/laravel-blade-comments
=============================

Add debug comments to your rendered output

2.0.2(2mo ago)177325.5k↑12.1%12MITPHPPHP ^8.2CI passing

Since May 30Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/spatie/laravel-blade-comments)[ Packagist](https://packagist.org/packages/spatie/laravel-blade-comments)[ Docs](https://github.com/spatie/laravel-blade-comments)[ RSS](/packages/spatie-laravel-blade-comments/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (28)Versions (21)Used By (0)

Add debug comments to your rendered output
------------------------------------------

[](#add-debug-comments-to-your-rendered-output)

[![Latest Version on Packagist](https://camo.githubusercontent.com/804e20076bb4f08ef7c4eeb4133d1febbe1143f6646ea07f592f50b10c33d265/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d626c6164652d636f6d6d656e74732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-blade-comments)[![GitHub Tests Action Status](https://camo.githubusercontent.com/017be02b38d0a21e540b4d23a26e507d9d3f69666b755683fe5b33cbdd7b8a57/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7370617469652f6c61726176656c2d626c6164652d636f6d6d656e74732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/spatie/laravel-blade-comments/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/b48054add1a9a4b64fe1c5f65312236855bd9c1d9eb426b09173ba2d453b0884/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7370617469652f6c61726176656c2d626c6164652d636f6d6d656e74732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/spatie/laravel-blade-comments/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/cbf6b26233fef9de1fda0abedc124060f558a3714d4a67b53b53454a2ee32ada/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d626c6164652d636f6d6d656e74732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-blade-comments)

When looking at the HTML of a rendered page, it might not be obvious to you anymore which Blade view is responsible for which HTML. This package will add HTML before and after each rendered view, so you immediately know to which Blade view / component to go to change the output.

When you inspect a part of the page using your favourite browser's dev tools, you'll immediately see which Blade view rendered that particular piece of content. Here's a demo where we inspected the breadcrumbs on [our own company site](https://spatie.be). It is immediately clear that the breadcrumbs are rendered by the `front.pages.docs.partials.breadcrumbs` Blade view.

[![screenshot](https://github.com/spatie/laravel-blade-comments/raw/main/docs/breadcrumbs.jpg)](https://github.com/spatie/laravel-blade-comments/blob/main/docs/breadcrumbs.jpg)

At the top of the HTML document, we'll also add some extra information about the topmost Blade view and the request.

[![screenshot](https://github.com/spatie/laravel-blade-comments/raw/main/docs/page.jpg)](https://github.com/spatie/laravel-blade-comments/blob/main/docs/page.jpg)

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/77c26afabb7f041c0d0bf38a5e6b82e2d346bddd4fb568d0a7e48f77859236ed/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d626c6164652d636f6d6d656e74732e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-blade-comments)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

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

[](#installation)

You can install the package via composer:

```
composer require spatie/laravel-blade-comments --dev
```

You can optionally publish the config file with:

```
php artisan vendor:publish --tag="blade-comments-config"
```

This is the content of the published config file:

```
return [
    'enable' => env('APP_DEBUG'),

    /**
     * Add a comment at the beginning and end of every blade
     * containing the relative path to the blade file.
     */
    'blade_paths' => true,

    /*
     * These classes provide regex for adding comments for
     * various Blade directives.
     */
    'blade_commenters' => [
        Spatie\BladeComments\Commenters\BladeCommenters\BladeComponentCommenter::class,
        Spatie\BladeComments\Commenters\BladeCommenters\ExtendsCommenter::class,
        Spatie\BladeComments\Commenters\BladeCommenters\IncludeCommenter::class,
        Spatie\BladeComments\Commenters\BladeCommenters\LivewireComponentCommenter::class,
        Spatie\BladeComments\Commenters\BladeCommenters\LivewireDirectiveCommenter::class,
        Spatie\BladeComments\Commenters\BladeCommenters\SectionCommenter::class,
    ],

    /*
     * These classes will add comments at the top of the response.
     */
    'request_commenters' => [
        Spatie\BladeComments\Commenters\RequestCommenters\ViewCommenter::class,
        Spatie\BladeComments\Commenters\RequestCommenters\RouteCommenter::class,
    ],

    /*
     * This middleware will add extra information about the request
     * to the start of a rendered HTML page.
     */
    'middleware' => [
        Spatie\BladeComments\Http\Middleware\AddRequestComments::class,
    ],

    /*
     * This class is responsible for calling the registered Blade commenters.
     * In most cases, you don't need to modify this class.
     */
    'precompiler' => Spatie\BladeComments\BladeCommentsPrecompiler::class,

    'excludes' => [
        /**
         * Add includes you don't want to be affected by the package here.
         * For example:
         *  'styles.theme',
         *  'partials.sidebar',
         */
        'includes' => [

        ],

        /**
         * Add sections you don't want to be affected by the package here.
         * These sections will not have HTML comments added around @yield directives
         * For example:
         *  'header',
         *  'message',
         */
        'sections' => [

        ],
    ],
];
```

Usage
-----

[](#usage)

After the package is installed, you'll immediately see that HTML comments are injected at the start and end of every Blade view.

Excluding views
---------------

[](#excluding-views)

Sometimes you might not want to have an HTML comment being wrapped around an include. For example when you use a partial to add some CSS to a page. In these cases you can add views to the `excludes.includes` array in the config file.

Excluding sections
------------------

[](#excluding-sections)

Sometimes you might not want HTML comments wrapping around `@yield` directives. For example when they're used within HTML attributes or meta tags. In these cases you can add sections to the `excludes.sections` array in the config file.

### Using your own Blade Commenters

[](#using-your-own-blade-commenters)

You can easily extend the package to add more comments. In the `blade_commenters` key of the `blade_commenters` config file, you can add your own `BladeCommenter`. A `BladeCommenter` is any class that implements the following interface:

```
namespace Spatie\BladeComments\Commenters\BladeCommenters;

interface BladeCommenter
{
    /*
     * Should return a regex pattern that will be used
     * in preg_replace.
     */
    public function pattern(): string;

    /*
     * Should return a replacement string that will be
     * used in preg_replace.
     */
    public function replacement(): string;
}
```

Take a look at the `BladeCommenters` that ship with the package for an example.

### Using your own request commenters

[](#using-your-own-request-commenters)

The package adds useful information about the request at the top of the HTML page. This is done by the so called request commenters . You'll find the default request commenters in the `request_commenters` key of the `blade-comments` config file.

You can add your own request commenters there. A `RequestCommentor` is any class that implements the following interface:

```
namespace Spatie\BladeComments\Commenters\RequestCommenters;

use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

interface RequestCommenter
{
    public function comment(Request $request, Response $response): ?string;
}
```

If the `comment` function returns a string, it will be injected at the top of the HTML document. Take a look at the request commenters that ship with the package for an example.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Tim Van Dijck](https://github.com/timvandijck)
- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

59

—

FairBetter than 99% of packages

Maintenance84

Actively maintained with recent releases

Popularity51

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~71 days

Recently: every ~93 days

Total

15

Last Release

80d ago

Major Versions

0.0.1 → 1.0.02023-05-30

1.4.0 → 2.02025-06-27

PHP version history (2 changes)0.0.1PHP ^8.1

1.3.1PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7535935?v=4)[Spatie](/maintainers/spatie)[@spatie](https://github.com/spatie)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (100 commits)")[![timvandijck](https://avatars.githubusercontent.com/u/4528796?v=4)](https://github.com/timvandijck "timvandijck (45 commits)")[![wvdongen](https://avatars.githubusercontent.com/u/1862615?v=4)](https://github.com/wvdongen "wvdongen (31 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (17 commits)")[![StyleShit](https://avatars.githubusercontent.com/u/32631382?v=4)](https://github.com/StyleShit "StyleShit (14 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (10 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (5 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (2 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (2 commits)")[![thecaliskan](https://avatars.githubusercontent.com/u/13554944?v=4)](https://github.com/thecaliskan "thecaliskan (1 commits)")[![utsavsomaiya](https://avatars.githubusercontent.com/u/96036522?v=4)](https://github.com/utsavsomaiya "utsavsomaiya (1 commits)")[![fsamapoor](https://avatars.githubusercontent.com/u/4992968?v=4)](https://github.com/fsamapoor "fsamapoor (1 commits)")

---

Tags

bladedevelopmentlaravelspatielaraveldebugbladeviewcommentslaravel-blade-comments

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/spatie-laravel-blade-comments/health.svg)

```
[![Health](https://phpackages.com/badges/spatie-laravel-blade-comments/health.svg)](https://phpackages.com/packages/spatie-laravel-blade-comments)
```

###  Alternatives

[daikazu/laravel-glider

Start using Glide on-the-fly instantly in your Laravel blade templates.

882.3k](/packages/daikazu-laravel-glider)[leitsch/kirby-blade

Enable Laravel Blade Template Engine for Kirby 4 and Kirby 5

219.2k](/packages/leitsch-kirby-blade)

PHPackages © 2026

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