PHPackages                             runopencode/assets-injection - 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. runopencode/assets-injection

ActiveLibrary

runopencode/assets-injection
============================

Assets dependency injection library.

59PHP

Since Sep 30Pushed 10y ago4 watchersCompare

[ Source](https://github.com/RunOpenCode/assets-injection)[ Packagist](https://packagist.org/packages/runopencode/assets-injection)[ RSS](/packages/runopencode-assets-injection/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Assets Injection
================

[](#assets-injection)

Assets injection library is missing assets management component that combines Dependency Injection and Assetic in one library that helps full stack developers/front end developers to include necessary javascripts and stylesheets into template without worrying about dependencies and order of inclusion.

If projects such as Bower or Components (or some other similar project) will help you to pull assets from Github to your project directory, this component will help you to include those assets into template.

How? Learn by example...
------------------------

[](#how-learn-by-example)

In this example, we will presume that you use Twig. So in your template:

```

        {% css %}

        {% inject 'my-asset-library' %}

        {% js %}

```

And let's say that it is defined that your library `my-asset-library` depends on `jquery-ui` and `jquery-ui` needs `jquery`, that would mean that you have to add that code to `HEAD`/`BODY` tag in correct order.

This library solves that issue, resolving all those dependencies, loading and injecting all required javascripts and stylesheets based on definitions of libraries. So, your result might look like:

```

```

**One single `{% inject "library-name" %}` will save you from all that hassle...!**

And that is not all - you can configure library to combine and compress all those assets into one file, so your result might look like this in production enviroment:

```

```

Do you see the magic?
---------------------

[](#do-you-see-the-magic)

Can you see that `LINK` tag in `HEAD` is rendered properly, even thoug assets are injected AFTER rendering logic? We didn't use `str_replace`, nor some nasty hacks - we made Twig to buffer its output and delay execution of portions of templates in order to achieve this result.

And this was not easy task, see: [Sonata base layout](https://github.com/sonata-project/SonataPageBundle/blob/master/Resources/views/base_layout.html.twig), note `{{ sonata_block_include_stylesheets('screen', app.request.basePath) }}` at the bottom - stylesheets are not loaded where they should be - in `HEAD` tag.

We figure out how to overcome above mentioned issue, and this library was developed having in mind Sonata and Drupal dynamic-block-like content.

In development
--------------

[](#in-development)

Note that this library is still under heavy development, and first release is expected in October, 2015, as well as Symfony bundle.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/410738?v=4)[Nikola Svitlica](/maintainers/TheCelavi)[@TheCelavi](https://github.com/TheCelavi)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/runopencode-assets-injection/health.svg)

```
[![Health](https://phpackages.com/badges/runopencode-assets-injection/health.svg)](https://phpackages.com/packages/runopencode-assets-injection)
```

PHPackages © 2026

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