PHPackages                             cethyworks/content-injector-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. cethyworks/content-injector-bundle

AbandonedArchivedSymfony-bundle[Utility &amp; Helpers](/categories/utility)

cethyworks/content-injector-bundle
==================================

Allow content injection before the app send the response to the client.

v5.0(6y ago)311.5k53MITPHPPHP ^7.1.3

Since Jul 6Pushed 6y ago1 watchersCompare

[ Source](https://github.com/Cethy/ContentInjectorBundle)[ Packagist](https://packagist.org/packages/cethyworks/content-injector-bundle)[ RSS](/packages/cethyworks-content-injector-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (14)Versions (9)Used By (3)

Cethyworks\\ContentInjectorBundle
=================================

[](#cethyworkscontentinjectorbundle)

Allow effective content injection before the app sends the response to the client.

It uses a global subscriber which will inject content from collected `InjectorCommands` when `kernel.response` event is fired. The `InjectorCommands` can be a simple `callable` returning a string or be as complex as a rendered twig template with data.

The bundle provides helpers to inject simple text, twig templates and `FormView` aware commands.

[![CircleCI](https://camo.githubusercontent.com/73e8103144f5dad7d609f95edfbd889db2227cf1bfa8e368b779c347434b997a/68747470733a2f2f636972636c6563692e636f6d2f67682f43657468792f436f6e74656e74496e6a6563746f7242756e646c652f747265652f6d61737465722e7376673f7374796c653d736869656c64)](https://circleci.com/gh/Cethy/ContentInjectorBundle/tree/master)

Install
-------

[](#install)

```
composer require cethyworks/content-injector-bundle

```

`AppKernel.php`

```
class AppKernel extends Kernel
{
	registerBundles()
	{
		return [
			// ...
			new Cethyworks\ContentInjectorBundle\CethyworksContentInjectorBundle()
		];
	}
}

```

How to use
----------

[](#how-to-use)

The global subscriber is configured out of the box.

You just need to register one or more `InjectorCommand` :

```
$subscriber = $container->get(ContentInjectorSubscriber::class);
$subscriber->regiterCommand(function(){ return 'inject_me'; });

```

### With twig template

[](#with-twig-template)

```
$commandHandler = $container->get(TwigCommandHandler::class);
$commandHandler->registerCommand('@AppBundle\Resources/assets/twig/foo.html.twig', ['foo' => 'bar']);

```

### With FormType

[](#with-formtype)

The bundle provides a `TypeExtension` "extending" `FormType` (virtually all forms) adding a `injector` option allowing the configuration of an injector aware of the FormType's `FormView`. It ca be used like this :

`AppInjectJsType.php`

```
class AppInjectJsType extends AbstractType
{
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
            'injector' => [
            	'template' => '@AppBundle/Resources/assets/twig/app_inject_js_type.html.twig' ]
        ));
    }

    public function getBlockPrefix()
    {
        return 'my_form_id';
    }

    public function getParent()
    {
        return EntityType::class;
    }
}

```

`app_inject_js_type.html.twig`

```

    var formId = "{{ form_view.vars['id'] }}";

    // do something to your form

```

What's in the box ?
-------------------

[](#whats-in-the-box-)

### EventSubscriber

[](#eventsubscriber)

- `Cethyworks\ContentInjectorBundle\EventSubscriber\ContentInjectorSubscriber($injector)`

Collects `InjectorCommands`, execute and inject them into the `Response` when `kernel.response` event is fired.

### Commands

[](#commands)

- `Cethyworks\ContentInjectorBundle\Command\CommandInterface`

Command interface.

- `Cethyworks\ContentInjectorBundle\Command\TextCommand($text)`

Simple Text Command.

- `Cethyworks\ContentInjectorBundle\Command\TwigCommand($twig)->setTemplate($template)->setData($data)`

Twig Command, render `$template` with `$data`.

### FormExtension

[](#formextension)

- `Cethyworks\ContentInjectorBundle\Form\Extension\InjectorAwareTypeExtension($commandFactory, $responseSubscriber)`

Enable the `injector` form option.

@see section **How to / With Form" ""Type** above.

### Factories

[](#factories)

- `Cethyworks\ContentInjectorBundle\Command\Factory\TwigFormCommandFactory`

Used internally by `InjectorAwareTypeExtension`, create TwigCommands aware of `FormView`.

### Injectors

[](#injectors)

- `Cethyworks\ContentInjectorBundle\Injector\InjectorInterface`

Injector interface.

- `Cethyworks\ContentInjectorBundle\Injector\BodyEndInjector`

Injects just before `` tag.

### Test helper

[](#test-helper)

- `Cethyworks\ContentInjectorBundle\Test\InjectorTypeTestCase`

### Command Handler

[](#command-handler)

- `Cethyworks\ContentInjectorBundle\Command\Handler\TwigCommandHandler`

Shorcut service to create &amp; register a `TwigCommand`.

Extends `TypeTestCase` and initialize the `InjectorAwareTypeExtension` extension.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 88.2% 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 ~124 days

Recently: every ~210 days

Total

8

Last Release

2357d ago

Major Versions

v1.0 → v2.02017-08-07

v2.2 → v3.02019-02-04

v3.0 → v4.02019-09-01

v4.1 → v5.02019-11-26

PHP version history (2 changes)v1.0PHP &gt;=5.6.17

v3.0PHP ^7.1.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/c0992307e9a9d414b451beb664b8313ed22f77d6b5b949a9f199b2114d6cae4d?d=identicon)[Cethy](/maintainers/Cethy)

---

Top Contributors

[![Cethy](https://avatars.githubusercontent.com/u/735030?v=4)](https://github.com/Cethy "Cethy (15 commits)")[![bjbahnhof](https://avatars.githubusercontent.com/u/99014513?v=4)](https://github.com/bjbahnhof "bjbahnhof (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cethyworks-content-injector-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/cethyworks-content-injector-bundle/health.svg)](https://phpackages.com/packages/cethyworks-content-injector-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M650](/packages/sylius-sylius)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M309](/packages/easycorp-easyadmin-bundle)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[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)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)

PHPackages © 2026

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