{"id":19325102,"url":"https://github.com/spatie/laravel-blade-comments","last_synced_at":"2025-04-07T21:09:24.632Z","repository":{"id":158145028,"uuid":"633851080","full_name":"spatie/laravel-blade-comments","owner":"spatie","description":"Add debug comments to your rendered output","archived":false,"fork":false,"pushed_at":"2025-02-21T09:38:08.000Z","size":793,"stargazers_count":166,"open_issues_count":3,"forks_count":10,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-04T15:56:16.241Z","etag":null,"topics":["blade","development","laravel"],"latest_commit_sha":null,"homepage":"https://freek.dev/2500-a-laravel-package-to-quickly-see-which-html-is-rendered-by-which-blade-view","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spatie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-28T12:32:24.000Z","updated_at":"2025-04-04T04:40:49.000Z","dependencies_parsed_at":"2023-12-13T14:41:52.990Z","dependency_job_id":"77be595f-f90f-4ae4-9c22-1632e4ae566b","html_url":"https://github.com/spatie/laravel-blade-comments","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":"spatie/package-skeleton-laravel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-blade-comments","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-blade-comments/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-blade-comments/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-blade-comments/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spatie","download_url":"https://codeload.github.com/spatie/laravel-blade-comments/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247730068,"owners_count":20986404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blade","development","laravel"],"created_at":"2024-11-10T02:08:55.627Z","updated_at":"2025-04-07T21:09:24.614Z","avatar_url":"https://github.com/spatie.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Add debug comments to your rendered output\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/laravel-blade-comments.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-blade-comments)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/spatie/laravel-blade-comments/run-tests.yml?branch=main\u0026label=tests\u0026style=flat-square)](https://github.com/spatie/laravel-blade-comments/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/spatie/laravel-blade-comments/fix-php-code-style-issues.yml?branch=main\u0026label=code%20style\u0026style=flat-square)](https://github.com/spatie/laravel-blade-comments/actions?query=workflow%3A\"Fix+PHP+code+style+issues\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/spatie/laravel-blade-comments.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-blade-comments)\n\nWhen 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.\n\nWhen 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.\n\n![screenshot](https://github.com/spatie/laravel-blade-comments/blob/main/docs/breadcrumbs.jpg)\n\nAt the top of the HTML document, we'll also add some extra information about the topmost Blade view and the request.\n\n![screenshot](https://github.com/spatie/laravel-blade-comments/blob/main/docs/page.jpg)\n\n## Support us\n\n[\u003cimg src=\"https://github-ads.s3.eu-central-1.amazonaws.com/laravel-blade-comments.jpg?t=1\" width=\"419px\" /\u003e](https://spatie.be/github-ad-click/laravel-blade-comments)\n\nWe 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).\n\nWe 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).\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require spatie/laravel-blade-comments --dev\n```\n\nYou can optionally publish the config file with:\n\n```bash\nphp artisan vendor:publish --tag=\"blade-comments-config\"\n```\n\nThis is the content of the published config file:\n\n```php\nreturn [\n    'enable' =\u003e env('APP_DEBUG'),\n\n    /*\n     * These classes provide regex for adding comments for\n     * various Blade directives.\n     */\n    'blade_commenters' =\u003e [\n        Spatie\\BladeComments\\Commenters\\BladeCommenters\\BladeComponentCommenter::class,\n        Spatie\\BladeComments\\Commenters\\BladeCommenters\\AnonymousBladeComponentCommenter::class,\n        Spatie\\BladeComments\\Commenters\\BladeCommenters\\ExtendsCommenter::class,\n        Spatie\\BladeComments\\Commenters\\BladeCommenters\\IncludeCommenter::class,\n        Spatie\\BladeComments\\Commenters\\BladeCommenters\\IncludeIfCommenter::class,\n        Spatie\\BladeComments\\Commenters\\BladeCommenters\\IncludeWhenCommenter::class,\n        Spatie\\BladeComments\\Commenters\\BladeCommenters\\LivewireComponentCommenter::class,\n        Spatie\\BladeComments\\Commenters\\BladeCommenters\\LivewireDirectiveCommenter::class,\n        Spatie\\BladeComments\\Commenters\\BladeCommenters\\SectionCommenter::class,\n    ],\n\n    /*\n     * These classes will add comments at the top of the response.\n     */\n    'request_commenters' =\u003e [\n        Spatie\\BladeComments\\Commenters\\RequestCommenters\\ViewCommenter::class,\n        Spatie\\BladeComments\\Commenters\\RequestCommenters\\RouteCommenter::class,\n    ],\n\n    /*\n     * This middleware will add extra information about the request\n     * to the start of a rendered HTML page.\n     */\n    'middleware' =\u003e [\n        Spatie\\BladeComments\\Http\\Middleware\\AddRequestComments::class,\n    ],\n\n    /*\n     * This class is responsible for calling the registered Blade commenters.\n     * In most case, you don't need to modify this class.\n     */\n    'precompiler' =\u003e Spatie\\BladeComments\\BladeCommentsPrecompiler::class,\n    \n    'excludes' =\u003e [\n        /**\n         * Add includes you don't want to be affected by the package here.\n         * For example:\n         *  'styles.theme',\n         *  'partials.sidebar',\n         */\n        'includes' =\u003e [\n\n        ]\n    ]\n];\n```\n\n## Usage\n\nAfter the package is installed, you'll immediately see that HTML comments are injected at the start and end of every Blade view.\n\n## Excluding views\nSometimes 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.\nIn these cases you can add views to the `excludes.includes` array in the config file.\n\n### Using your own Blade Commenters\n\nYou 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:\n\n```php\nnamespace Spatie\\BladeComments\\Commenters\\BladeCommenters;\n\ninterface BladeCommenter\n{\n    /*\n     * Should return a regex pattern that will be used\n     * in preg_replace. \n     */\n    public function pattern(): string;\n\n    /*\n     * Should return a replacement string that will be\n     * used in preg_replace.\n     */\n    public function replacement(): string;\n}\n```\n\nTake a look at the `BladeCommenters` that ship with the package for an example.\n\n### Using your own request commenters\n\nThe 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. \n\nYou can add your own request commenters there. A `RequestCommentor` is any class that implements the following interface:\n\n```php\nnamespace Spatie\\BladeComments\\Commenters\\RequestCommenters;\n\nuse Illuminate\\Http\\Request;\nuse Symfony\\Component\\HttpFoundation\\Response;\n\ninterface RequestCommenter\n{\n    public function comment(Request $request, Response $response): ?string;\n}\n```\n\nIf 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.\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Tim Van Dijck](https://github.com/timvandijck)\n- [Freek Van der Herten](https://github.com/freekmurze)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Flaravel-blade-comments","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspatie%2Flaravel-blade-comments","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Flaravel-blade-comments/lists"}