2017 © Pedro Peláez
 

symfony-bundle php-vars-to-js-bundle

Transformation of PHP vars to JS for Symfony2 with Twig

image

hospect/php-vars-to-js-bundle

Transformation of PHP vars to JS for Symfony2 with Twig

  • Tuesday, August 8, 2017
  • by holyspecter
  • Repository
  • 2 Watchers
  • 8 Stars
  • 7,559 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 4 Versions
  • 5 % Grown

The README.md

Build Status, (*1)

Description

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

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

Installation

Simply require it with composer:, (*3)

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

And register in your AppKernel.php:, (*4)

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

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

    return $bundles;
}

Usage

In your controller call:, (*5)

$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):, (*6)

<script>
    {{ initPhpVars() }}
</script>

The Versions

08/08 2017

dev-master

9999999-dev

Transformation of PHP vars to JS for Symfony2 with Twig

  Sources   Download

MIT

The Requires

 

The Development Requires

by hospect

08/08 2017

1.0.2

1.0.2.0

Transformation of PHP vars to JS for Symfony2 with Twig

  Sources   Download

MIT

The Requires

 

The Development Requires

by hospect

23/01 2017

1.0.1

1.0.1.0

Transformation of PHP vars to JS for Symfony2 with Twig

  Sources   Download

MIT

The Requires

 

The Development Requires

by hospect

22/02 2016

1.0.0

1.0.0.0

Transformation of PHP vars to JS for Symfony2 with Twig

  Sources   Download

The Requires

 

The Development Requires

by hospect