Git Product home page Git Product logo

laravel-view-xray's Introduction

Xray - Take a look into your Laravel views

Latest Version on Packagist Build Status Quality Score Total Downloads

When your Laravel project grows, so do the Laravel views. Sometimes it might be hard to figure out, which part of the output HTML was rendered using which template. With this package, you can take a peek into your Laravel views and find out which template is responsible for which part of the output HTML.

Example output

Installation

You can install the package via composer:

composer require beyondcode/laravel-view-xray --dev

The package is enabled by default - so all you need to do is visit your application in the browser and hit the Xray shortcut.

  • Windows: CTRL + Shift + X
  • OSX: CMD + Shift + X

This toggles the Xray view, where you can see which view (and optionally section) rendered the visual output.

Disabling Xray

You can disable Xray by setting an environment variable called XRAY_ENABLED to false.

Excluding views

If you want to exclude certain views from being processed by Xray, you can do this by adding them to the configuration file.

Publish the configuration file using:

php artisan vendor:publish --provider=BeyondCode\\ViewXray\\ViewXrayServiceProvider

This will publish a file called xray.php in your config folder.

This is the content of the configuration file:

<?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' => [
        //
    ],

];

Just place the view names that you want to exclude in the excluded array.

FAQ

  • Does this work with VueJS too?

Yes, this package does work in combination with VueJS, but you need to enable comments in your VueJS app. This package works by adding specific HTML comments into the rendered views and uses these comments to find the bounding boxes of the rendered HTML. VueJS by default removes HTML comments prior to rendering.

You can enable HTML comments in your VueJS app by setting comments to true:

let app = new Vue({
    el: '#content',
    comments: true
});

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

This project is inspired by xray-rails.

License

The MIT License (MIT). Please see License File for more information.

laravel-view-xray's People

Contributors

bmichotte avatar ltkort avatar matthewnessworthy avatar mpociot avatar raakesh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-view-xray's Issues

Linux shortcut (not working maybe)

I am not sure if I am doing something wrong. But in Linux machine (Ubuntu) control shift x is not working. I can see in the html code that xray did put some of its tags in the source code, but I am not able to activate the x ray view.

JS error when returning simple view

First of all - thank you for having made this wonderfull package, it eases a lot the production flow !

A JS error occurs when XRay is enabled and a simple view, whitout extending layout, is returned.

In my case I run an Jquery Ajax Type & Search, wich return html result in simple blade view. This JS error impacts other consequent callbacks binded to my function. If XRay is disabled, eveything goes fine.

Uncaught TypeError: Xray.Overlay is not a constructor at HTMLDocument.eval (eval at globalEval (jquery-2.1.4.min.js:2), <anonymous>:31:7) at j (jquery-2.1.4.min.js:2) at Object.add [as done] (jquery-2.1.4.min.js:2) at n.fn.init.n.fn.ready (jquery-2.1.4.min.js:2) at new n.fn.init (jquery-2.1.4.min.js:2) at n (jquery-2.1.4.min.js:2) at eval (eval at globalEval (jquery-2.1.4.min.js:2), <anonymous>:30:12) at eval (eval at globalEval (jquery-2.1.4.min.js:2), <anonymous>:35:5) at eval (eval at globalEval (jquery-2.1.4.min.js:2), <anonymous>:322:3) at eval (<anonymous>)

Throwing Exception

Stack Trace

[stacktrace]
#0 /home/vagrant/Sites/ensdevc.com/vendor/beyondcode/laravel-view-xray/src/XrayMiddleware.php(47): BeyondCode\\ViewXray\\XrayMiddleware->injectXrayBar(Object(Illuminate\\Http\\Response))
#1 /home/vagrant/Sites/ensdevc.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): BeyondCode\\ViewXray\\XrayMiddleware->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#2 /home/vagrant/Sites/ensdevc.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#3 /home/vagrant/Sites/ensdevc.com/vendor/beyondcode/laravel-query-detector/src/QueryDetectorMiddleware.php(33): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#4 /home/vagrant/Sites/ensdevc.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): BeyondCode\\QueryDetector\\QueryDetectorMiddleware->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#5 /home/vagrant/Sites/ensdevc.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#6 /home/vagrant/Sites/ensdevc.com/vendor/barryvdh/laravel-debugbar/src/Middleware/InjectDebugbar.php(65): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#7 /home/vagrant/Sites/ensdevc.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Barryvdh\\Debugbar\\Middleware\\InjectDebugbar->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#8 /home/vagrant/Sites/ensdevc.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#9 /home/vagrant/Sites/ensdevc.com/vendor/genealabs/laravel-casts/src/Http/Middleware/AssetInjection.php(10): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#10 /home/vagrant/Sites/ensdevc.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): GeneaLabs\\LaravelCasts\\Http\\Middleware\\AssetInjection->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#11 /home/vagrant/Sites/ensdevc.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#12 /home/vagrant/Sites/ensdevc.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#13 /home/vagrant/Sites/ensdevc.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#14 /home/vagrant/Sites/ensdevc.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#15 /home/vagrant/Sites/ensdevc.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#16 /home/vagrant/Sites/ensdevc.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#17 /home/vagrant/Sites/ensdevc.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#18 /home/vagrant/Sites/ensdevc.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#19 /home/vagrant/Sites/ensdevc.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#20 /home/vagrant/Sites/ensdevc.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#21 /home/vagrant/Sites/ensdevc.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#22 /home/vagrant/Sites/ensdevc.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#23 /home/vagrant/Sites/ensdevc.com/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#24 /home/vagrant/Sites/ensdevc.com/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#25 /home/vagrant/Sites/ensdevc.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#26 /home/vagrant/Sites/ensdevc.com/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#27 /home/vagrant/Sites/ensdevc.com/public/index.php(53): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#28 {main}

Add Livewire Support

Hello everyone !

I encountered a problem with the package & the use of LiveWire and after long research I finally found how to solve the problem and especially the cause!

There are several solutions, disable the package altogether, which I wouldn't like to do.

Exclude all views from livewire, which I don't intend to do. (the folders are unfortunately not taken into account in the package)

Or add a little thing here && !Str::contains($view->getName(), 'livewire')

$this->modifyView($view);

Can you add Directory support && Livewire support ?

Good night !

Linux/Chrome Hotkey Ctrl + Shift + X doesn't seem to work

For Linux and Google Chrome Browser, the Hotkey Ctrl + Shift + X doesn't seem to work. The hotkey seems to be in use elsewhere (I don't know if it's chrome itself or an addon). Is it possible to change the hot-key for X-Ray using Configuration-File?

Wrong image url

Hello,

On the documentation, the image could not be displayed due to the wrong source.

<p><img src="/img/docs/laravel-view-xrayhttps://beyondco.de/github/xray/xray.png" alt="Example output"></p>

Update PHP-Version requirement to PHP 8?

Hello,
is it possible to rise PHP-Version requirement to PHP 8? I'm currently unable to composer-require this package due to the strict requirement of ^php7.1 in your composer.json. Is it at least compatible to php7.4 or even php8.0?

Laravel 5.7

I saw composer.json was already updated, could you please tag a release now 5.7 is out? โค๏ธ

injectXrayBar needs api or route exclude

Hi there!
while trying to listen the auth broadcast channel receiving

"message": "Call to a member function getPath() on null","exception": "Symfony\\Component\\Debug\\Exception\\FatalThrowableError", "file": "C:\\xampp\\htdocs\\dev\\neomed-dev\\vendor\\beyondcode\\laravel-view-xray\\src\\XrayMiddleware.php", "line": 102,

using
Laravel 5.6.*,
beyondcode/laravel-view-xray ^1.0,
Laravel echo server.

GitHub link package differs from composer file

Hey @mpociot ๐Ÿ‘‹

Thanks for this package! Would be good rename the GitHub link package from beyondcode/laravel-xray to beyondcode/laravel-view-xray.

In order to keep the same name that already exists in composer.json and namespaces.

screenshot 2018-07-19 13 24 55

screenshot 2018-07-19 13 25 23

Response breaks when adding parenthesis in @section value

It seems that response breaks when adding a title containing a string value with parenthesis:

@section('title', 'Foo (bar)')

Results in:

<?php $__env->startSection; ?>('title', 'Foo (bar)<!--XRAY START 1 todo.orders@section:title, Foo (bar

Conflicting Shortcuts

When I first took this package for a spin I noticed that the shortcut conflicted with the XDebug helper Chrome extension at least on Mac: command + shift + X.

I don't know if this is an edge-case with any other extensions, but it might be useful to have configurable keyboard shortcuts or some kind of callback a user can register that the xray JS defers to.

I'm open to helping if you have any ideas, otherwise, at least documenting it here. โค๏ธ

Overlay not appearing

Installed it on two different projects and tested both in multiple browsers. Both projects are using Laravel 5.6 & PHP 7.2.7 all with the same results.

I'm able to see the Xray comments in the browsers inspector, but nothing happens when I hit the shortcut (on a Mac).

Just a tip for those having issues...

Like many others here, I too had an issue where nothing would happen, but I could see the comments in the HTML. There was no error message, no "Ready to Xray. Press cmd+shift+x to scan your UI.".

Many may not know or even notice, but the loading of the default Laravel app.js (which includes jQuery) in layouts/app.blade.php is deferred.

Meaning the inline Xray script ends up being run before the app.js and exits because jQuery has not yet loaded.

Replacing
<script src="{{ mix('js/app.js') }}" defer></script>

with

<script src="{{ mix('js/app.js') }}"></script>

Or even

<script src="{{ mix('js/app.js') }}" {{env('APP_ENV') !== 'production' ? '' : 'defer'}}></script>

will fix the issue.

Add Laravel 8 support

On installing with composer is gives an error:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for beyondcode/laravel-view-xray ^1.3 -> satisfiable by beyondcode/laravel-view-xray[1.3.0].
    - Installation request for laravel/framework (locked at v8.10.0, required as ^8.0) -> satisfiable by laravel/framework[v8.10.0].
     - Can only install one of: laravel/framework[8.x-dev, 5.7.x-dev].
    - Can only install one of: laravel/framework[v8.0.0, 5.7.x-dev].
    - Can only install one of: laravel/framework[v8.0.1, 5.7.x-dev].
    - Can only install one of: laravel/framework[v8.0.2, 5.7.x-dev].
    - Can only install one of: laravel/framework[v8.0.3, 5.7.x-dev].
    - Can only install one of: laravel/framework[v8.0.4, 5.7.x-dev].
    - Can only install one of: laravel/framework[v8.1.0, 5.7.x-dev].
    - Can only install one of: laravel/framework[v8.10.0, 5.7.x-dev].
    - Can only install one of: laravel/framework[v8.2.0, 5.7.x-dev].
    - Can only install one of: laravel/framework[v8.3.0, 5.7.x-dev].
    - Can only install one of: laravel/framework[v8.4.0, 5.7.x-dev].
    - Can only install one of: laravel/framework[v8.5.0, 5.7.x-dev].
    - Can only install one of: laravel/framework[v8.6.0, 5.7.x-dev].
    - Can only install one of: laravel/framework[v8.7.0, 5.7.x-dev].
    - Can only install one of: laravel/framework[v8.7.1, 5.7.x-dev].
    - Can only install one of: laravel/framework[v8.8.0, 5.7.x-dev].
    - Can only install one of: laravel/framework[v8.9.0, 5.7.x-dev].
    - Can only install one of: laravel/framework[5.7.x-dev, v8.10.0].
    - Conclusion: install laravel/framework 5.7.x-dev
    - Installation request for laravel/framework ^8.0 -> satisfiable by laravel/framework[8.x-dev, v8.0.0, v8.0.1, v8.0.2, v8.0.3, v8.0.4, v8.1.0, v8.10.0, v8.2.0, v8.3.0, v8.4.0, v8.5.0, v8.6.0, v8.7.0, v8.7.1, v8.8.0, v8.9.0].

Shortcut not working

I installed this plugin via composer, after installing I refreshed the web page, but it did nothing. I was doubtful either its content is loading or not, but its content is being loaded at last of the page source, but it's doing nothing. I haven't installed xbeug chrome extension that may conflict with the shortcut key.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.