PHPackages                             rtablada/inspector-gadget - 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. rtablada/inspector-gadget

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

rtablada/inspector-gadget
=========================

A web-component inspired data flow library for Laravel views.

1.1.0(10y ago)51.2kMITPHPPHP &gt;=5.4.0

Since Mar 8Pushed 10y ago2 watchersCompare

[ Source](https://github.com/rtablada/inspector-gadget)[ Packagist](https://packagist.org/packages/rtablada/inspector-gadget)[ Docs](https://github.com/rtablada/inspector-gadget)[ RSS](/packages/rtablada-inspector-gadget/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelogDependencies (5)Versions (5)Used By (0)

Inspector Gadget
================

[](#inspector-gadget)

[![Latest Version](https://camo.githubusercontent.com/bebd62bf39e4133a58a3e373cdedac9d9324aa724f842b0febb6ecd1c47aa3c6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f727461626c6164612f696e73706563746f722d6761646765742e7376673f7374796c653d666c61742d737175617265)](https://github.com/rtablada/inspector-gadget/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/5bb7c361881132fb0c229c27c2f69f6339b43e658bde67e493f9ae0da54ccee0/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f727461626c6164612f696e73706563746f722d6761646765742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/rtablada/inspector-gadget)[![Total Downloads](https://camo.githubusercontent.com/2cfcbca6fa71def8e62819a183262da01072b5c8a4473072ceb527c60341fe0b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f727461626c6164612f696e73706563746f722d6761646765742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rtablada/inspector-gadget)

Inspector Gadget is a [web-component](https://css-tricks.com/modular-future-web-components/) and [Ember.js](http://emberjs.com) inspired library for improving data-flow, maintainability, and template reusability.

Gadgets, in inspector gadget allow for template partials or even plain strings to be rendered in a smart, explicit fashion while reducing weight and overloaded controllers or domain layers.

Install
-------

[](#install)

Via Composer

```
$ composer require rtablada/inspector-gadget
```

In the `app.php` config file, add `'Rtablada\InspectorGadget\GadgetServiceProvider',` to the `providers` array.

Then publish the configuration file with `php artisan vendor:publish` to publish the `config/inspector-gadget.php` file.

**Note**

You can optionally install install the `Rtablada\InspectorGadget\Facades\Gadget'` to the facades array as `Gadget` to use gadget facades in your views.

Usage
-----

[](#usage)

### Gadget Classes

[](#gadget-classes)

Gadgets are just plain PHP objects with a `render` method. The string returned by the `render` function will be sent back to your views. Since the gadgets are resolved using the application container, you can dependency inject like any other class in your application.

```
class ExampleGadget
{
    public function render()
    {
        return 'this string will be returned';
    }
}
```

### Making Gadgets with the GadgetFactory

[](#making-gadgets-with-the-gadgetfactory)

In you views, you can render gadgets using the `make` function on the `gadgetFactory` variable that is available in your views. The `make` function accepts a string argument for the gadget class that you want to render in your view.

```
$gadgetFactory->make('ExampleGadget'); // returns 'this string will be returned'
```

### Passing Arguments to Gadgets

[](#passing-arguments-to-gadgets)

To allow greater flexibility, you can pass arguments to the `render` function in your gadget.

```
// app/Gadgets/ArgumentGadget.php
class ArgumentGadget
{
    public function render($str)
    {
        return $str . ' from gadget';
    }
}

// view.php
$gadgetFactory->make('ArgumentGadget', 'test'); // returns 'test from gadget'
```

### Shortcuts

[](#shortcuts)

If you have registered the `Gadget` facade, then you can have the following in your views:

```
Gadget::make('ExampleGadget');
```

If you're using blade templates, there is a `@gadget` helper that calls `$gadgetFactory->make()`

```
@gadget('ExampleGadget')
```

### Better Data Flow

[](#better-data-flow)

Consider the following controller action:

```
public function show($id)
{
    $post = $this->post->find($id);
    $relevantPosts = $this->suggestionEngine->relevantPosts($post);
    $comments = $this->comment->allForPost($post);

    $user = $this->auth->user();

    $userHistory = $this->historyCache->historyForUser($user);
    // etc.

    return view('post.show', compact('post', 'relevantPosts', 'comments', 'user', 'userHistory', '...'));
}
```

And the accompanying view:

```

        History

        Things You Might Like

```

This can be cleaned up using gadgets:

```
// Controller
public function show($id)
{
    $post = $this->post->find($id);
    $user = $this->auth->user();

    return view('post.show', compact('post', 'user'));
}
```

```
// View

        History
        @gadget('UserPostHistory', $user)

        Things You Might Like
        @gadget('RelevantPosts', $post)

```

Configuring
-----------

[](#configuring)

### Default Namespace

[](#default-namespace)

To shorten the need for full class names in your `Gadget::make` calls, Inspector Gadget has a `namespace` configuration option in the `config/inspector-gadget.php` file. This is used as a default namespace to look up gadgets. If a class is not found in your configured default namespace, then Inspector Gadget will attempt to load from the full class name.

### Aliases

[](#aliases)

To further shorthand and ease, you can register aliases in the `aliases` array in the `config/inspector-gadget.php` file. This allows for gadgets to be aliased without poluting the app container.

Testing
-------

[](#testing)

```
$ phpunit
```

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

[](#contributing)

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

Security
--------

[](#security)

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

Credits
-------

[](#credits)

- [Ryan Tablada](https://github.com/rtablada)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

30

—

LowBetter than 65% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Total

3

Last Release

3870d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ea9ccd400c74151601341e320935a31d1a9779c5eb49a8f364bc7a0ac75baa32?d=identicon)[rtablada](/maintainers/rtablada)

---

Top Contributors

[![rtablada](https://avatars.githubusercontent.com/u/2532004?v=4)](https://github.com/rtablada "rtablada (9 commits)")

---

Tags

rtabladainspector-gadget

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rtablada-inspector-gadget/health.svg)

```
[![Health](https://phpackages.com/badges/rtablada-inspector-gadget/health.svg)](https://phpackages.com/packages/rtablada-inspector-gadget)
```

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[illuminate/view

The Illuminate View package.

13144.9M1.7k](/packages/illuminate-view)[moonshine/moonshine

Laravel administration panel

1.3k217.1k59](/packages/moonshine-moonshine)[tallstackui/tallstackui

TallStackUI is a powerful suite of Blade components that elevate your workflow of Livewire applications.

703141.0k7](/packages/tallstackui-tallstackui)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

44643.1k1](/packages/pressbooks-pressbooks)[livewire/blaze

A tool for optimizing Blade component performance by folding them into parent templates

688221.3k17](/packages/livewire-blaze)

PHPackages © 2026

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