PHPackages                             jguido/widget-bundle - 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. jguido/widget-bundle

ActiveSymfony-bundle

jguido/widget-bundle
====================

This Bundle add a widget system for rendering data a generic way. It also permit a generation of widget files.

0.2.2(9y ago)0111GNUPHPPHP &gt;=5.5.6

Since Oct 15Pushed 8y ago1 watchersCompare

[ Source](https://github.com/jguido/widget-bundle)[ Packagist](https://packagist.org/packages/jguido/widget-bundle)[ RSS](/packages/jguido-widget-bundle/feed)WikiDiscussions master Synced 2mo ago

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

Installation
============

[](#installation)

```
composer require jguido/widget-bundle

```

Then add this bundle to your kernel (app/AppKernel.php) :

```
new WidgetBundle\WidgetBundle(),
new ApplicationWidgetBundle\ApplicationWidgetBundle(),

```

Add in app/config/routing.yml

```
bundle_widget:
    resource: "@WidgetBundle/Resources/config/routing.yml"
    prefix:   /

```

Add in app/config/config.yml in import section

```
- { resource: "@ApplicationWidgetBundle/Resources/config/widgets.yml" }

```

Add this line in the style declaration of your layout

```

```

Add this line in the javascript declaration of your layout

```

```

Usage
=====

[](#usage)

There is a command for generating files of the desired widget :

```
php bin/console generate:widget

```

The rendering of a widget is done like this

The simpliest way

```
{{ render_widget('widget.') }}

```

If the route of your widget needs parameters

```
{{ render_widget('widget.', {'param1': param1}) }}

```

But if you do so, you will have to update the route definition in the file of your bundle (in src/ApplicationWidgetBundle/Widget/your\_widget)

Content of the widget is loaded with ajax calls, all the dom events are functionnals (window.onload, $(function){...});)

File structure : src -- ApplicationWidgetBundle ----Resources ------config --------widgets.yml (the widgets service definition) ------views (where the views generated are placed) ----Widget (inside all the widget (controller) class

Example (Use case)
==================

[](#example-use-case)

You want to generate a bundle "test"

in console :

```
php bin/console generate:widget test

```

What i will have in the service definition (src/ApplicationWidgetBundle/Resources/config/widgets.yml):

```
services:

    widget.test:
        class: ApplicationWidgetBundle\Widget\TestWidget

```

Inside the widget class:

```
