PHPackages                             elnur/abstract-controller-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. [Framework](/categories/framework)
4. /
5. elnur/abstract-controller-bundle

ActiveSymfony-bundle[Framework](/categories/framework)

elnur/abstract-controller-bundle
================================

Simplifies doing controllers as services

v0.2.1(12y ago)1420.8k3[1 issues](https://github.com/elnur/ElnurAbstractControllerBundle/issues)MITPHPPHP &gt;=5.3.3

Since Aug 16Pushed 12y ago2 watchersCompare

[ Source](https://github.com/elnur/ElnurAbstractControllerBundle)[ Packagist](https://packagist.org/packages/elnur/abstract-controller-bundle)[ RSS](/packages/elnur-abstract-controller-bundle/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (4)Versions (4)Used By (0)

ElnurAbstractControllerBundle
=============================

[](#elnurabstractcontrollerbundle)

So, you decided to [define your controllers as services](http://symfony.com/doc/current/cookbook/controller/service.html)? That's great! But isn't injecting the same basic services into each controllers tedious and boring? Not anymore!

The abstract controller of this bundle is automatically injected with the following commonly used services:

- `form.factory`,
- `router`,
- `translator`,
- `security.context`,
- `session`, and
- `templating`.

It also provides a couple of helper methods:

- `getUser()` — to get the currently logged in user;
- `addFlash($type, $message)` — to add a flash message to the session.

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

[](#installation)

1. Add this to `composer.json`:

    ```
    {
        "require": {
            "elnur/abstract-controller-bundle": "dev-master"
        }
    }

    ```

    And run:

    ```
    composer update elnur/abstract-controller-bundle

    ```
2. Enable the bundle in `app/AppKernel.php`:

    ```
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Elnur\AbstractControllerBundle\ElnurAbstractControllerBundle(),
        );
    }

    ```

Usage
-----

[](#usage)

Make your controller extend the `AbstractController` class:

```
