• Reading time ~ 1 min
  • 01.06.2023

With the Laravel Blade Comments package by Spatie, you can add debug comments to your rendered Blade template output:

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.

Given the following simple blade template, you will find useful information like which view, route, layout, and files are used to render the page:

@extends('app')

@section('body')
    <h1>Hello, World!</h1>
    @include('example')
@endsection

Given the above simple template, the output might look like the following for an invokable controller rendering a view called hello-world:

<!-- View: hello-world -->
<!-- Route: App\Http\Controllers\HelloWorldController (hello-world) -->
<!-- View extends: app -->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Hello World</title>
</head>
<body>
<!-- Start section: body -->
    <h1>Hello, World!</h1>
<!-- Start include: example -->
    <p>This is an example include file.</p>
<!-- End include: example -->
<!-- End section: body -->
</body>
</html>

To use this package, you can check it out at spatie/laravel-blade-comments on GitHub. Freek also wrote about this package, sharing some valuable tips along the way, including the Blade precompiler method.

Comments

No comments yet
Yurij Finiv

Yurij Finiv

Full stack

ABOUT

Professional Fullstack Developer with extensive experience in website and desktop application development. Proficient in a wide range of tools and technologies, including Bootstrap, Tailwind, HTML5, CSS3, PUG, JavaScript, Alpine.js, jQuery, PHP, MODX, and Node.js. Skilled in website development using Symfony, MODX, and Laravel. Experience: Contributed to the development and translation of MODX3 i...

About author CrazyBoy49z
WORK EXPERIENCE
Contact
Ukraine, Lutsk
+380979856297