rosio/php-to-javascript-variables
Composer 安装命令:
composer require rosio/php-to-javascript-variables
包简介
README 文档
README
Simple package which allows easy sharing of variables from PHP to JavaScript. This is a rewrite of the laracasts/utilities package. I was prompted to do this due to the aformentioned package requiring PHP 5.4+, and I disliked their design.
Installation
composer.json
"require": { ... "rosio/php-to-javascript-variables": "~1.0" }
config/app.php
'providers' => array( ... 'Rosio\PhpToJavaScriptVariables\PhpToJavaScriptVariablesServiceProvider', ),
Usage
controllers\HomeController.php
public function showWelcome() { JSLocalize::put(array( 'variableName' => 'variableValue', 'anotherVariable' => array(1, 2, 3) )); return View::make('hello'); }
views\hello.php
<!doctype html> <html lang="en"> <head> ... {{ App::make('JSLocalizeDumper')->dump() }} ... </head> <body> <script type="text/javascript"> alert(app.variableName); </script> </body> </html>
统计信息
- 总下载量: 151
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2014-05-04