PHP code example of irishdan / js-settings-bundle

1. Go to this page and download the library: Download irishdan/js-settings-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/ */

    

irishdan / js-settings-bundle example snippets



// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new IrishDan\JsSettingsBundle\JsSettingsBundle(),
        );
        // ...
    }
    // ...
}

    - { resource: "@JsSettingsBundle/Resources/config/services.yml" }

js_settings:
    object_name: 'JsData'
    defaults:
        local: "%locale%"
        page_data:
            site: 'www.example.com'

// The key can be a string...
$this->get('js_settings.settings')->addData('key', $values);

// The key can be an array...
$this->get('js_settings.settings')->addData(['first_key', 'second_key'], $values);

// The key can be index notation
$this->get('js_settings.settings')->addData('[first_key][second_key]', $values);


$this->get('js_settings.settings')->pushData('[first_key][second_key]', $values);

{{ get_js_settings() }}