PHPackages                             yavin/symfony-init-controller - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. yavin/symfony-init-controller

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

yavin/symfony-init-controller
=============================

Runs init controller method before every action

v0.4(10y ago)23.9k1MITPHPPHP &gt;=5.3.9

Since Dec 20Pushed 10y ago1 watchersCompare

[ Source](https://github.com/Yavin/symfony-init-controller)[ Packagist](https://packagist.org/packages/yavin/symfony-init-controller)[ RSS](/packages/yavin-symfony-init-controller/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (2)Dependencies (3)Versions (6)Used By (0)

Symfony Init Controller extension
=================================

[](#symfony-init-controller-extension)

[![Build Status](https://camo.githubusercontent.com/af7483e929034e341f6e86905d67bc98d9a46191edc4324e43528fcf024c3338/68747470733a2f2f7472617669732d63692e6f72672f596176696e2f73796d666f6e792d696e69742d636f6e74726f6c6c65722e737667)](https://travis-ci.org/Yavin/symfony-init-controller)

Add ability to execute `init` method in controller before every action. Based on [this answer](http://stackoverflow.com/a/11179521/1051297)

Example
-------

[](#example)

```
class SampleController extends Controller implements InitControllerInterface
{
    protected $page;

    public function init(Request $request)
    {
        if ($request->get('redirect') == 1) {
            return $this->redirect('http://example.com');
        }

       $this->page = $request->get('page');
    }

    public function indexAction()
    {
        //some action code
    }
}
```

Instalation
-----------

[](#instalation)

1. Add library to composer.json

    ```
    "yavin/symfony-init-controller": "0.3"
    ```

    and run command

    ```
    composer update yavin/symfony-init-controller

    ```
2. Add service in your bundle services file `Resources/config/services.xml`:

    ```

    ```

    or if you have `services.yml`:

    ```
    services:
        symfony.controller.subscriber.init:
            class: Yavin\Symfony\Controller\InitControllerSubscriber
            tags:
                - { name: kernel.event_subscriber }
    ```
3. Then implement `InitControllerInterface` in controller that you want to have init method.

    ```
    namespace Acme\DemoBundle\Controller;

    use Symfony\Bundle\FrameworkBundle\Controller\Controller;
    use Symfony\Component\HttpFoundation\Request;
    use Yavin\Symfony\Controller\InitControllerInterface;

    class SampleController extends Controller implements InitControllerInterface
    {
        protected $page;

        public function init(Request $request)
        {
            //init method could return response, for example redirect
            if ($request->get('redirect') == 1) {
                return $this->redirect('http://example.com');
            }

            $this->page = $request->get('page');
        }

        public function indexAction()
        {
            //...
        }

        public function otherAction()
        {
            //...
        }
    }
    ```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~292 days

Total

4

Last Release

3697d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3f940c22f0438a9116e869ec843e7e46ea6d430b7acf4424ac5c93805521592b?d=identicon)[Yavin](/maintainers/Yavin)

---

Top Contributors

[![Yavin](https://avatars.githubusercontent.com/u/1175856?v=4)](https://github.com/Yavin "Yavin (13 commits)")

### Embed Badge

![Health badge](/badges/yavin-symfony-init-controller/health.svg)

```
[![Health](https://phpackages.com/badges/yavin-symfony-init-controller/health.svg)](https://phpackages.com/packages/yavin-symfony-init-controller)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M379](/packages/easycorp-easyadmin-bundle)[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k246.0M11.2k](/packages/symfony-framework-bundle)[symfony/security-bundle

Provides a tight integration of the Security component into the Symfony full-stack framework

2.5k181.3M2.2k](/packages/symfony-security-bundle)[shopware/storefront

Storefront for Shopware

684.6M217](/packages/shopware-storefront)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
