PHP code example of hospect / php-vars-to-js-bundle

1. Go to this page and download the library: Download hospect/php-vars-to-js-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hospect / php-vars-to-js-bundle example snippets


public function registerBundles()
{
    $bundles = array(
        // some other bundles...
        
        new \Hospect\PhpVarsToJsBundle\HospectPhpToJsBundle(),
    );
        
    return $bundles;
}

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