PHPackages                             jmikola/js-assets-helper-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. [Templating &amp; Views](/categories/templating)
4. /
5. jmikola/js-assets-helper-bundle

ActiveSymfony-bundle[Templating &amp; Views](/categories/templating)

jmikola/js-assets-helper-bundle
===============================

Exposes the AssetsHelper service from Symfony2's templating component to JavaScript, allowing relative or absolute asset URI's to be generated client-side.

v1.0.1(13y ago)1912.6k4MITJavaScriptPHP &gt;=5.3.2

Since Feb 26Pushed 13y ago5 watchersCompare

[ Source](https://github.com/jmikola/JmikolaJsAssetsHelperBundle)[ Packagist](https://packagist.org/packages/jmikola/js-assets-helper-bundle)[ Docs](https://github.com/jmikola/JmikolaJsAssetsHelperBundle)[ RSS](/packages/jmikola-js-assets-helper-bundle/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

JmikolaJsAssetsHelperBundle
===========================

[](#jmikolajsassetshelperbundle)

This bundle exposes the AssetsHelper service from Symfony2's templating component to JavaScript, which allows relative or absolute asset URI's to be generated client-side.

Compatibility
-------------

[](#compatibility)

This bundle depends [PR #2502](https://github.com/symfony/symfony/pull/2502), which is included in Symfony 2.0.5 and higher.

Configuration
-------------

[](#configuration)

If you do not configure the bundle explicitly, it will only expose the default package defined in the `templating` block of the FrameworkBundle configuration.

Named packages you wish to expose must be explicitly listed:

```
jmikola_js_assets_helper:
    packages_to_expose: [ cloudfront, s3 ]
```

While an array of package names is the normal format, the configuration will also accept a scalar to expose a single package:

```
jmikola_js_assets_helper:
    packages_to_expose: cloudfront
```

In these examples, "cloudfront" and "s3" correspond to named packages in the FrameworkBundle configuration. For example:

```
framework:
    templating:
        # The default package will be a PathPackage
        assets_version:        123
        assets_version_format: "%%s?version=%%s"
        packages:
            # The cloudfront package will be a UrlPackage
            cloudfront:
                version:        123
                version_format: "%%s?version=%%s"
                base_urls:      https://example.cloudfront.net
```

Additional information on configuring templating asset packages may be found in the [FrameworkBundle docs](http://symfony.com/doc/current/reference/configuration/framework.html#templating).

### Routing

[](#routing)

The bundle defines one route to a dynamically generated JavaScript file. Ensure this route is including in your application's routing configuration:

```
jmikola_js_assets_helper:
    resource: "@JmikolaJsAssetsHelperBundle/Resources/config/routing/routing.xml"
```

### Assets

[](#assets)

The bundle includes a compiled JavaScript asset, which must be published to your `web/` directory:

```
$ php app/console assets:install --symlink web
```

Include the compiled and dynamic JavaScript in your applications template:

```

```

Usage
-----

[](#usage)

Once configured, the bundle creates a single `AssetsHelper` global in JavaScript. This is modeled after the PHP class from Symfony2's Templating component and has the following methods:

```
/**
 * Returns the public path.
 *
 * Absolute paths (i.e. http://...) are returned unmodified.
 *
 * @param string path        A public path
 * @param string packageName A package name (optional)
 *
 * @return string A public path which takes into account the base path and URL path
 */
function getUrl(path, packageName);

/**
 * Gets the version to add to public URL.
 *
 * @param string packageName A package name (optional)
 * @return string The current version
 */
function getVersion(packageName);
```

Typically, you will want to use the `getUrl()` method to generate asset paths. Keep in mind that if you refer to a named package that has not been exposed, an `InvalidPackageError` will be thrown.

The following equivalent snippets demonstrate how `AssetsHelper.getUrl()`compares to Symfony2's asset helper for Twig:

```
// JavaScript
'';
```

```
{# Twig #}

```

Development
-----------

[](#development)

Note: This bundle includes a static JavaScript asset, which is pre-compiled with Google's [Closure Compiler](http://code.google.com/closure/compiler/). Any changes to the static JavaScript will require that you recompile the asset. For your convenience, you may want to install [JMSGoogleClosureBundle](https://github.com/schmittjoh/JMSGoogleClosureBundle) and use the following command:

```
$ php app/console plovr:build @JmikolaJsAssetsHelperBundle/compile.js
```

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 79.1% 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 ~117 days

Total

2

Last Release

4756d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/49096f4052ca788ddf49c82e835125294f460f155885aa3e1ada8c3ff4f4a648?d=identicon)[jmikola](/maintainers/jmikola)

---

Top Contributors

[![jmikola](https://avatars.githubusercontent.com/u/244663?v=4)](https://github.com/jmikola "jmikola (34 commits)")[![stof](https://avatars.githubusercontent.com/u/439401?v=4)](https://github.com/stof "stof (9 commits)")

---

Tags

javascriptJSassetsAssetsHelper

### Embed Badge

![Health badge](/badges/jmikola-js-assets-helper-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/jmikola-js-assets-helper-bundle/health.svg)](https://phpackages.com/packages/jmikola-js-assets-helper-bundle)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-bundle)[sylius/sylius

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

8.5k5.9M733](/packages/sylius-sylius)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k12](/packages/2lenet-crudit-bundle)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.8M505](/packages/pimcore-pimcore)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M563](/packages/shopware-core)

PHPackages © 2026

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