PHPackages                             hostnet/hn-dependency-injection-plugin - 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. [Database &amp; ORM](/categories/database)
4. /
5. hostnet/hn-dependency-injection-plugin

AbandonedArchivedLibrary[Database &amp; ORM](/categories/database)

hostnet/hn-dependency-injection-plugin
======================================

Introduces the Symfony DI container in a Symfony 1 application.

4.0.2(4y ago)1644.2k11MITPHPPHP &gt;=7.3

Since Aug 29Pushed 4y ago6 watchersCompare

[ Source](https://github.com/hostnet/hnDependencyInjectionPlugin)[ Packagist](https://packagist.org/packages/hostnet/hn-dependency-injection-plugin)[ RSS](/packages/hostnet-hn-dependency-injection-plugin/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (29)Used By (0)

hnDependencyInjectionPlugin
===========================

[](#hndependencyinjectionplugin)

- Introduces the Symfony 2 DI container in a Symfony 1 application.
- Transforms a Symfony 2 doctrine configuration into a format readable for Symfony 1.x. Use Doctrine entities and propel classes with the same database configuration!

[![Total Downloads](https://camo.githubusercontent.com/1ef281342c0cf843796b270434bd4dee8dbb1f69bc9d443370bd0272fe790e43/68747470733a2f2f706f7365722e707567782e6f72672f686f73746e65742f686e2d646570656e64656e63792d696e6a656374696f6e2d706c7567696e2f646f776e6c6f6164732e706e67)](https://packagist.org/packages/hostnet/hn-dependency-injection-plugin)[![Build Status](https://github.com/hostnet/hnDependencyInjectionPlugin/actions/workflows/main.yaml/badge.svg)](https://github.com/hostnet/hnDependencyInjectionPlugin/actions/workflows/main.yaml)

### Installation

[](#installation)

1. [Download Composer](http://getcomposer.org/doc/00-intro.md).
2. Run `php composer.phar require hostnet/hn-dependency-injection-plugin`
3. Make `apps//config/Configuration` extend `Hostnet\HnDependencyInjectionPlugin\ApplicationConfiguration`.
4. \[Optional\] override the `getKernel` method to return your own kernel, registering the bundles you want. ```
    protected function createKernel()
    {
        return new MyKernel($this);
    }

    ```

    ```
    class MyKernel extends Hostnet\HnDependencyInjectionPlugin\Symfony1Kernel
    {
        public function registerBundles()
        {
            $bundles = array(
                new Symfony\Bundle\FrameworkBundle\FrameworkBundle()
            );
            return array_merge($bundles, parent::registerBundles());
        }
    }

    ```
5. Create `apps//config/config.yml` to configure your [Doctrine dbal](http://symfony.com/doc/current/reference/configuration/doctrine.html#doctrine-dbal-configuration), [Doctrine orm](http://symfony.com/doc/current/reference/configuration/doctrine.html#configuration-overview), and possibly the [FrameworkBundle](http://symfony.com/doc/current/reference/configuration/framework.html). See also the [example configuration](https://github.com/symfony/symfony-standard/blob/master/app/config/config.yml).
6. If you don't want to generate the propel backwards compatability layer, add this ```
    parameters:
        hn_entities_enable_backwards_compatible_connections: false

    ```

    to `config.yml`, or `parameters.yml` if you prefer to have them separate.
7. To ensure proper autoloading when using Doctrine entities, remove if you have ```
    require_once __DIR__ . '/../vendor/autoload.php';

    ```

    and add the following to your `config/ProjectConfiguration.php`. ```
    use Doctrine\Common\Annotations\AnnotationRegistry;

    $loader = require __DIR__.'/../vendor/autoload.php';
    AnnotationRegistry::registerLoader(array($loader, 'loadClass'));

    ```

    That way Doctrine knows where to find your entities.
8. Be sure to set up your permissions properly, see "[Setting up your permissions](http://symfony.com/doc/current/book/installation.html#configuration-and-setup)".
9. After this is done we can do a little cleanup. To prevent confusion you should remove `config/databases.yml`, since only the Symfony 2 configuration is read at this point.

### Changelog

[](#changelog)

2.0.0

- Removed the Symfony1Panel class, it's added automatically now.

1.1.0

- Added a web debug panel with a link to the Symfony 2 profiler.

For this you need to activate the WebProfilerBundle, which you should only activate in dev

```
if ($this->getEnvironment() == 'dev') {
    $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
}

```

Then you need to configure the WebProfilerBundle and the profiler; add this to your config\_dev.yml:

```
web_profiler:
    toolbar: true
framework:
    router:   { resource: "%kernel.root_dir%/../config/sf2_routing_dev.yml" }
    profiler:
        only_exceptions: false
        only_master_requests: true

```

Add this to `sf2_routing_dev.yml` to make the WebProfilerBundle accessible:

```
_wdt:
    resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
    prefix:   /_wdt

_profiler:
    resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
    prefix:   /_profiler

_main:
    resource: sf2_routing.yml

```

And in web/\*.php, replace `$configuration->handle($request)->send();` with:

```
$response = $configuration->handle($request);
$response->send();
$configuration->terminate($request, $response);

```

You should now have a new panel in the Symfony 1 web debug toolbar with a link to the Symfony 2 profiler!

1.0.0

- First official release

0.15

- Added `hn_entities_enable_backwards_compatible_connections` parameter

### Running the unit-tests

[](#running-the-unit-tests)

1. Clone the repository yourself
2. Go to the directory of the clone
3. Run `composer.phar install`
4. Run `phpunit`

### Moving the error handling to Symfony 2

[](#moving-the-error-handling-to-symfony-2)

When migrating, you will eventually hit a point where you want to log errors properly. By default the `sfFrontWebController` contains a try catch block where exceptions will be caught. In order to move all error handling to Symfony 2, you can create your own front controller. If you remove the try catch in this front controller, all errors will be caught by the Symfony 2 uncaught exception handler.

If your route is matched with the sf1 route but sf1 doesn't know about the route, it will throw an `sf404ErrorException`. This exception will be caught and wrapped into an `HttpNotFoundException` and the `kernel.exception` will be fired eventually. This will make sure you can handle all exceptions in Symfony 2.

Additionally, you can throw exceptions in sf1 such as `AccessDeniedException`, `NotFoundHttpException`, `\RuntimeException` etc. They will all be caught. In case of a 404 error, the sf1 fallback will only be triggered once and can only be triggered as a first controller. Once you've succesfully entered Symfony 2 via either the sf1 route or the normal entry, it will no longer be initiated.

To add the front controller, you will have to set it in `factories.yml`.

```
all:
  controller:
    class: MyCustomFrontController
```

To enable the Symfony2 404 handling, you will have to set the following parameter to true:

```
hn_entities_enable_symfony2_404: true
```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor3

3 contributors hold 50%+ of commits

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 ~110 days

Recently: every ~449 days

Total

28

Last Release

1665d ago

Major Versions

1.2.0 → 2.0.02014-04-08

2.5.0 → 3.0.02016-01-27

3.2.0 → 4.0.02019-11-05

PHP version history (6 changes)1.0.0PHP &gt;=5.3

2.4.0PHP &gt;=5.4

3.0.0PHP &gt;=5.5

3.2.0PHP &gt;=5.6

4.0.0PHP &gt;=7.1

4.0.1PHP &gt;=7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/65433e1ef6edb2e8f96e18614b6618c84eed20ad0de6de0d0da36a9032ec7a18?d=identicon)[hostnet](/maintainers/hostnet)

---

Top Contributors

[![nicoschoenmaker](https://avatars.githubusercontent.com/u/1469323?v=4)](https://github.com/nicoschoenmaker "nicoschoenmaker (9 commits)")[![yannickl88](https://avatars.githubusercontent.com/u/5468127?v=4)](https://github.com/yannickl88 "yannickl88 (8 commits)")[![nutama](https://avatars.githubusercontent.com/u/9001392?v=4)](https://github.com/nutama "nutama (7 commits)")[![mvannes](https://avatars.githubusercontent.com/u/8969371?v=4)](https://github.com/mvannes "mvannes (4 commits)")[![eddypouw](https://avatars.githubusercontent.com/u/8748009?v=4)](https://github.com/eddypouw "eddypouw (2 commits)")[![hboomsma](https://avatars.githubusercontent.com/u/1465009?v=4)](https://github.com/hboomsma "hboomsma (2 commits)")[![stefanlenselink](https://avatars.githubusercontent.com/u/834562?v=4)](https://github.com/stefanlenselink "stefanlenselink (2 commits)")[![linaori](https://avatars.githubusercontent.com/u/1754678?v=4)](https://github.com/linaori "linaori (1 commits)")[![janlam7](https://avatars.githubusercontent.com/u/5459235?v=4)](https://github.com/janlam7 "janlam7 (1 commits)")[![janhohner](https://avatars.githubusercontent.com/u/649895?v=4)](https://github.com/janhohner "janhohner (1 commits)")[![FlorisTurkenburg](https://avatars.githubusercontent.com/u/2980570?v=4)](https://github.com/FlorisTurkenburg "FlorisTurkenburg (1 commits)")[![mdeheij](https://avatars.githubusercontent.com/u/9057191?v=4)](https://github.com/mdeheij "mdeheij (1 commits)")

---

Tags

symfonycontainerdependency-injectiondoctrine

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hostnet-hn-dependency-injection-plugin/health.svg)

```
[![Health](https://phpackages.com/badges/hostnet-hn-dependency-injection-plugin/health.svg)](https://phpackages.com/packages/hostnet-hn-dependency-injection-plugin)
```

###  Alternatives

[damienharper/auditor-bundle

Integrate auditor library in your Symfony projects.

4542.8M](/packages/damienharper-auditor-bundle)[sonata-project/doctrine-orm-admin-bundle

Integrate Doctrine ORM into the SonataAdminBundle

46117.7M155](/packages/sonata-project-doctrine-orm-admin-bundle)[fresh/doctrine-enum-bundle

Provides support of ENUM type for Doctrine2 in Symfony applications.

4636.8M12](/packages/fresh-doctrine-enum-bundle)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1022.4k](/packages/rcsofttech-audit-trail-bundle)[ahmed-bhs/doctrine-doctor

Runtime analysis tool for Doctrine ORM integrated into Symfony Web Profiler. Unlike static linters, it analyzes actual query execution at runtime to detect performance bottlenecks, security vulnerabilities, and best practice violations during development with real execution context and data.

813.1k](/packages/ahmed-bhs-doctrine-doctor)

PHPackages © 2026

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