In this article, I’m going to share with you one wonderful Laravel resource “Laravel View X-Ray”. Sometimes it might be hard to figure out, which part of the output HTML was rendered using which template.
Installation Laravel View X-Ray
Use the given command to install the package using the composer.
composer require beyondcode/laravel-view-xray --dev
No need to enable this package because it’s enabled by default.
You need to do is visit your application in the browser and use the given shortcuts as per your operating system.
- Windows: CTRL + Shift + X
- OSX: CMD + Shift + X
This shortcut toggles the X-Ray view, where we can see which view rendered the visual output.
You can use the given command to publish the package default configuration file. This file xray.php is located at the config folder.
php artisan vendor:publish --provider=BeyondCode\\ViewXray\\ViewXrayServiceProvider
And file contains some configuration such as:
<?php return [ /* * Determines if the Xray package should be enabled. */ 'enabled' => env('XRAY_ENABLED', true), /* * If you want to exclude certain views from being processed by Xray, * you can list them here. Be aware that the check only applies to the * root views that you add here. If these views include other views * themselves, they need to be excluded manually. */ 'excluded' => [ // ], ];
If, you want to exclude any view from this package then just add view name in the excluded array.
You can disable the Laravel View X-Ray package by setting an environment variable XRAY_ENABLED to false.