PHPackages                             schubu/laravel-widgets - 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. schubu/laravel-widgets

ActiveLibrary

schubu/laravel-widgets
======================

Feature your blade view files with widgets to keep your controller classes clean

1.0.0(6y ago)118MITPHPPHP ^7.2CI failing

Since Oct 20Pushed 6y ago1 watchersCompare

[ Source](https://github.com/SchuBu/laravel-widgets)[ Packagist](https://packagist.org/packages/schubu/laravel-widgets)[ Docs](https://github.com/schubu/laravel-widgets)[ RSS](/packages/schubu-laravel-widgets/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Laravel Widget Package - keep your controllers clean and DRY
============================================================

[](#laravel-widget-package---keep-your-controllers-clean-and-dry)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ff72bc70c3582d863fc19c0df935500f42003162f84c17e036591046e2502a03/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7363687562752f6c61726176656c2d776964676574732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/schubu/laravel-widgets)[![Build Status](https://camo.githubusercontent.com/7fb36abccd84256fd52df99643413517cc05711176de6a51af31ed7713e18c7b/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7363687562752f6c61726176656c2d776964676574732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/schubu/laravel-widgets)[![Quality Score](https://camo.githubusercontent.com/13acc8a45f8ae8e219ab1fd3596053d1d224237da5582aa1d1e6a131e77a3fd8/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7363687562752f6c61726176656c2d776964676574732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/schubu/laravel-widgets)[![Total Downloads](https://camo.githubusercontent.com/d9ecd4b5ae5ee75abafb02d17c75f09386c6831b0f5a7205a6b4287f6aaf4c47/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7363687562752f6c61726176656c2d776964676574732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/schubu/laravel-widgets)

A laravel widget package based on [the laracasts episode](https://laracasts.com/series/building-laracasts/episodes/2). It helps you to keep your controller clean and DRY.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require schubu/laravel-widgets
```

Usage
-----

[](#usage)

### Artisan command

[](#artisan-command)

You can create a widget by running this artisan command:

```
php artisan make:widget ExampleWidget
```

It will two folders:

- a `Widget` folder within the `app/Http` directory
- a `widget` folder within the `resource/views` directory

This task also places a class file and a blade file to get started.

- `app/Http/ExampleWidget.php`
- `resource/views/example-widget.blade.php`

### Blade @widget directive

[](#blade-widget-directive)

You can easily include your widget by using this blade directive:

`@widget('ExampleWidget')'`

### Passing data to your widget

[](#passing-data-to-your-widget)

You can pass data in two ways:

- define a public property
- define a public method

The public methods and properties will be passed as variables to your blade view!

#### Example

[](#example)

Your class:

```
namespace App\Http\Widgets;

use SchuBu\LaravelWidgets\LaravelWidgets;

class ExampleWidget extends LaravelWidgets
{
    public $exampleData = "Welcome to your widget!";

    public function exampleMethod()
    {
        return [
            "My first data",
            "My second data",
            "My third data"
        ];
    }
}
```

In your blade you can access your data this way:

```
This is {{ $exampleData }} awesome!
@foreach($exampleMethod as $content)
    {{ $content }}
@endforeach
```

### Specifying the blade filename

[](#specifying-the-blade-filename)

You can customize the blade filename by adding an additional parameter to the artisan command:

```
php artisan make:widget ExampleWidget MyExampleWidget
```

That results in a blade file named `my-example-widget.blade.php`. The generated class now contains an additional protected property `$viewPath`

```
namespace App\Http\Widgets;

use SchuBu\LaravelWidgets\LaravelWidgets;

class ExampleWidget extends LaravelWidgets
{
  protected $viewPath = 'widgets.my-example-widget';
  ...
}
```

### Testing

[](#testing)

Because I'm new to testing, no testing at all happened :-(.

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

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

[](#contributing)

This is my first package ever. So hope you'll contribute and help improving it. 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)

- [Peter Schulze-Buxloh](https://github.com/schubu)
- [Jeffrey Way](https://gist.github.com/JeffreyWay)
- [Marcel Pociot](https://github.com/mpociot)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

Laravel Package Boilerplate
---------------------------

[](#laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

2394d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6f0a9c4d63038e4321c6c9dc7e9b531297a996806848dabb5bdaac75a97fcfd4?d=identicon)[SchuBu](/maintainers/SchuBu)

---

Top Contributors

[![SchuBu](https://avatars.githubusercontent.com/u/30638214?v=4)](https://github.com/SchuBu "SchuBu (3 commits)")

---

Tags

schubularavel-widgets

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/schubu-laravel-widgets/health.svg)

```
[![Health](https://phpackages.com/badges/schubu-laravel-widgets/health.svg)](https://phpackages.com/packages/schubu-laravel-widgets)
```

PHPackages © 2026

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