A powerful laravel widget package. capsulate ui componenet as widget. similar to Yii widgets

v1.0.0 2018-01-22 07:31 UTC

This package is auto-updated.

Last update: 2024-02-21 19:19:10 UTC


Laravel widget package for Laravel >= 5.1


composer require morilog/widgetify

Register in Laravel

  • Add Morilog\Widgetify\WidgetifyServiceProvider to config/app.php providers array

  • If you need to Facade for rendering widgets, add bellow in config/app.php aliases array :

	'Widgetify' => Morilog\Widgetify\Facades\Widgetify::class
  • For publish Widgetify config file, run this command:
php artisan vendor:publish --provider="Morilog\Widgetify\WidgetifyServiceProvider"


Create new widget

For creating new widget you must create a class that extended Morilog\Widgetify\Widget and implement handle() method.

namespace App\MyWidgets;

use Morilog\Widgetify\Widget;

class SimpleWidget extends Widget
	public function handle()
		$latestPosts = Post::take(10)->get();

		return view('', compact('latestPosts'));

Registering Widget

  • Add your widget to widgets array in config/widgetify.php file:
	'widgets' => [
		'simple_widget' => App\MyWidgets\SimpleWidget::class

Rendering Widgets

With blade @widgetify directive:

// views/sidebar.blade.php
<div class="col-sm-3">

OR with configs:

// views/sidebar.blade.php
<div class="col-sm-3">
	@widgetify('simple_widget', ['key' => 'value', 'key2' => 'value'])

OR with Widgetify Facade:

// views/sidebar.blade.php
<div class="col-sm-3">
	{!! Widgetify::render('simple_widgets') !!}

Using cache

// views/default.blade.php
<div class="col-sm-4">
    {!! Widgetify::remember('my_widget', 15, [CONFIGS]); !!}
<div class="col-sm-4">
    @cached_widgetify('my_widget', 15, [CONFIGS]);