PHPackages                             breda/laravel-alpha-widget - 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. breda/laravel-alpha-widget

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

breda/laravel-alpha-widget
==========================

Simple Widget Manager For Laravel 5

1.0.0(11y ago)7252PHP

Since Mar 26Pushed 8y ago2 watchersCompare

[ Source](https://github.com/breda/laravel-alpha-widget)[ Packagist](https://packagist.org/packages/breda/laravel-alpha-widget)[ Docs](https://github.com/breda/laravel-alpha-widget)[ RSS](/packages/breda-laravel-alpha-widget/feed)WikiDiscussions master Synced 1mo ago

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

AlphaWidget — Widgets For Laravel 5
===================================

[](#alphawidget--widgets-for-laravel-5)

---

This is a very simple, easy to use Widget manager for [Laravel 5](http://laravel.com)

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

[](#installation)

First, install the package via [Composer](https://getcomposer.org/).

```
$ composer require breda/laravel-alpha-widget
```

in the `config/app.php` file, add the Service Provider

```
	'providers' => [
		// Other providers...
		'BReda\AlphaWidget\ServiceProvider',
	]
```

Then, register the alias :

```
	'aliases' => [
		// Other aliases...
		'AlphaWidget' => 'BReda\AlphaWidget\Facades\AlphaWidget',
		// Of course, you can name the alias to whatever you want.
		// ex:
		// 'Widget' => 'BReda\AlphaWidget\Facades\AlphaWidget',
	]
```

And, lastly... publish the AlphaWidget configuration file to your `config` directory:

```
$ php artisan vendor:publish
```

And you're ready to use AlphaWidget!

---

Walk Through
------------

[](#walk-through)

Now, when I said that this is a simple Widget manager, I meant it! It's as simple as registering a widget alias, and it's class inside the configuration file. Like this :

```
	'widgets' => [
		// Other widgets...
		'myRecentUsersWidget' => 'RecentUsers',
	]
```

> One note to take here before we move on, is that I'am only referencing the class name, not the complete namespace. And that's what the `namespace` field in the `config/alphaWidget.php` file is here for.

> To shorten class names, put your desired namespace in the config file, just make sure that all of your widget classes declare that namespace, that's all!

And then, calling the widget is as simple as :

```
	AlphaWidget::render('myRecentUsersWidget');

	// Or, a much better way:
	AlphaWidget::myRecentUsersWidget();
```

Now, what does that `RecentUsers` look like, I hear you say! It's a simple class implementing the `AlphaWidget` Contract (interface), stating that it must have the `render` method. That method, is responsible of rendering the widget contents.

```
