Package Data | |
---|---|
Maintainer Username: | moon0326 |
Maintainer Contact: | jeffrey@laracasts.com (Jeffrey Way) |
Package Create Date: | 2015-07-28 |
Package Last Update: | 2015-07-28 |
Home Page: | https://packagist.org/packages/laracasts/utilities |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-19 03:10:58 |
Package Statistics | |
---|---|
Total Downloads: | 163 |
Monthly Downloads: | 2 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
This is forked version of https://github.com/laracasts/PHP-Vars-To-Js-Transformer
Goal of this fork: Remove framework and ViewBinder dependency to make it usable in any PHP projects.
####Changes
{ "require": { "moon/utilities-javascript": "~1.0" } }
use Moon\Utilities\Javascript\PHPToJavaScriptTransformer;
$transformer = new PHPToJavaScriptTransformer;
// example 1
$javascript = $transformer->set('name', 'moon')
->set('age', 999999)
->transform()
// example 2
$javascript = $transformer->transform([
'name' => 'moon',
'age' => 999999
]);
// in your view
<script><?=$javascript?></script>