PHPackages                             starychfojtu/viewcomponent - 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. starychfojtu/viewcomponent

ActiveSymfony-bundle[Templating &amp; Views](/categories/templating)

starychfojtu/viewcomponent
==========================

Implementation of View Components for Symfony 3.3

v0.4.0(8y ago)02.0k1MITPHPPHP ^7.1

Since Jun 18Pushed 8y ago1 watchersCompare

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

READMEChangelog (9)Dependencies (8)Versions (10)Used By (0)

ViewComponentBundle
===================

[](#viewcomponentbundle)

Implementation of View Components for Symfony 3.3

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

[](#installation)

```
$ composer require starychfojtu/viewcomponent

```

Symfony flex might register incorrect namespace in bundles.php. If it did, go ahead and register it yourself with

```
'ViewComponent\ViewComponentBundle' => ['all' => true]
```

Configuration
=============

[](#configuration)

```
starychfojtu_view_component:
    component_dirs: ['AppBundle/Component', 'AppBundle/SpecialComponent'] #results in '/src/AppBundle/Component', '/src/AppBundle/Component/specialComponent'
    # Specify directories where the bundle should search for components from /src
    template_dirs: ['components', 'specialComponents'] #results in '/templates/components', '/templates/specialComponents'
    # Specify directories where the bundle should search for templates from /templates
```

Usage
=====

[](#usage)

First specify your view component by creating a class in configured directories and implement `ViewComponentInterface`. The render method returns associative array of objects that are passed to the view.

YOU HAVE TO NAME YOUR COMPONENT IN THIS WAY : YourSpecialNameViewComponent It is a classic CamelCase naming e.g. MenuViewComponent or CartSummaryViewComponent.

```
# src/AppBundle/Component/MenuViewComponent
