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 3d 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 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

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

3650d 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

[pugx/autocompleter-bundle

Add an autocomplete type to forms

93861.6k3](/packages/pugx-autocompleter-bundle)[codefog/contao-haste

haste extension for Contao Open Source CMS

42650.8k139](/packages/codefog-contao-haste)[netgen/layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.

3689.4k10](/packages/netgen-layouts-core)[codefog/contao-news_categories

News Categories bundle for Contao Open Source CMS

3183.3k6](/packages/codefog-contao-news-categories)[netgen/content-browser

Netgen Content Browser is a Symfony bundle that provides an interface which selects items from any kind of backend and returns the IDs of selected items back to the calling code.

14112.1k8](/packages/netgen-content-browser)[leapt/core-bundle

Symfony LeaptCoreBundle

2529.1k4](/packages/leapt-core-bundle)

PHPackages © 2026

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