Download the PHP package elnur/abstract-controller-bundle without Composer
On this page you can find all versions of the php package elnur/abstract-controller-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download elnur/abstract-controller-bundle
More information about elnur/abstract-controller-bundle
Files in elnur/abstract-controller-bundle
Package abstract-controller-bundle
Short Description Simplifies doing controllers as services
License MIT
Informations about the package abstract-controller-bundle
ElnurAbstractControllerBundle
So, you decided to define your controllers as services? 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
, andtemplating
.
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
-
Add this to
composer.json
:{ "require": { "elnur/abstract-controller-bundle": "dev-master" } }
And run:
composer update elnur/abstract-controller-bundle
-
Enable the bundle in
app/AppKernel.php
:public function registerBundles() { $bundles = array( // ... new Elnur\AbstractControllerBundle\ElnurAbstractControllerBundle(), ); }
Usage
Make your controller extend the AbstractController
class:
<?php
namespace Acme\Bundle\AppBundle\Controller;
use Elnur\AbstractControllerBundle\AbstractController;
class UserController extends AbstractController
{
// ...
}
And define elnur.controller.abstract
as the parent service:
services:
user_controller:
class: Acme\Bundle\AppBundle\Controller\UserController
parent: elnur.controller.abstract
License
This bundle is under the MIT license. See the complete license in the bundle:
Resources/meta/LICENSE
All versions of abstract-controller-bundle with dependencies
symfony/framework-bundle Version ~2.1
symfony/security Version ~2.1
symfony/form Version ~2.1