dowilcox/javascript-variables

Pass varaibles from PHP to JavaScript.

1.0.1 2015-03-10 11:26 UTC

This package is not auto-updated.

Last update: 2024-11-09 17:56:03 UTC


README

Send variables into JavaScript. Can be used standalone or with a Laravel service provider.

Installation

Add to your composer.json file

"dowilcox/javascript-variables": "dev-master"
$jsVar = new Dowilcox\JsVar\JsVar('namespace');

Installation (Laravel)

In config/app.php add the service provider and alias.

'Dowilcox\JsVar\JsVarServiceProvider',
'JsVar' => 'Dowilcox\JsVar\Facades\JsVar',

Example

$jsVar->add('key', 'value');

echo $jsVar->dump();

Will output:

window.namespace = window.namespace || {key: 'value'};