PHPackages                             hospect/php-vars-to-js-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. hospect/php-vars-to-js-bundle

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

hospect/php-vars-to-js-bundle
=============================

Transformation of PHP vars to JS for Symfony2 with Twig

1.0.2(8y ago)931.6k↓46.2%1MITPHP

Since Feb 22Pushed 4y ago2 watchersCompare

[ Source](https://github.com/holyspecter/HospectPhpVarsToJsBundle)[ Packagist](https://packagist.org/packages/hospect/php-vars-to-js-bundle)[ RSS](/packages/hospect-php-vars-to-js-bundle/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (4)Versions (4)Used By (0)

[![Build Status](https://camo.githubusercontent.com/21c27477e71da9a55af84710667853ef15a4641099dae9f7772ea1c2fb520c45/68747470733a2f2f7472617669732d63692e6f72672f686f6c79737065637465722f486f737065637450687056617273546f4a7342756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/holyspecter/HospectPhpVarsToJsBundle)

### Description

[](#description)

Bundle allows you to avoid horrible statements in Twig templates while setting JS variables from PHP ones, like:

```
var someJsVar = '{{ somePhpVar }}',
    anotherJsVar = '{{ anotherPhpVar }}';
```

### Installation

[](#installation)

Simply require it with composer:

```
composer require hospect/php-vars-to-js-bundle
```

And register in your `AppKernel.php`:

```
public function registerBundles()
{
    $bundles = array(
        // some other bundles...

        new \Hospect\PhpVarsToJsBundle\HospectPhpToJsBundle(),
    );

    return $bundles;
}
```

### Usage

[](#usage)

In your controller call:

```
$this->get('php_to_js')->put([
    'someJsVar' => $somePhpVar,
    // more vars here...
]);
```

Then in Twig template (probably that will be useful to move it to layout):

```

    {{ initPhpVars() }}

```

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 76.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 ~267 days

Total

3

Last Release

3252d ago

### Community

Maintainers

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

---

Top Contributors

[![holyspecter](https://avatars.githubusercontent.com/u/4248110?v=4)](https://github.com/holyspecter "holyspecter (16 commits)")[![bocharsky-bw](https://avatars.githubusercontent.com/u/3317635?v=4)](https://github.com/bocharsky-bw "bocharsky-bw (3 commits)")[![anacona16](https://avatars.githubusercontent.com/u/2333731?v=4)](https://github.com/anacona16 "anacona16 (1 commits)")[![salemgolemugoo](https://avatars.githubusercontent.com/u/1916111?v=4)](https://github.com/salemgolemugoo "salemgolemugoo (1 commits)")

---

Tags

phpsymfony-bundletwig-templates

### Embed Badge

![Health badge](/badges/hospect-php-vars-to-js-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/hospect-php-vars-to-js-bundle/health.svg)](https://phpackages.com/packages/hospect-php-vars-to-js-bundle)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M387](/packages/easycorp-easyadmin-bundle)[shopware/storefront

Storefront for Shopware

684.6M236](/packages/shopware-storefront)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)[symfony/ux-toolkit

A tool to easily create a design system in your Symfony app with customizable, well-crafted Twig components

16126.1k1](/packages/symfony-ux-toolkit)[open-dxp/opendxp

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

9421.6k61](/packages/open-dxp-opendxp)[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.

1189.8k](/packages/rcsofttech-audit-trail-bundle)

PHPackages © 2026

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