netherphp/onescript
Composer 安装命令:
composer require netherphp/onescript
包简介
A silly Javascript Compiler.
关键字:
README 文档
README
A silly Javascript "Compiler"
The only things I dislike more than Javascript are other people's Javascript frameworks and build systems. So like a complete tool I wrote my own that works in the way I typically build my scripts.
Use Case
Pretending our website project is setup like this.
- Our Project Root:
/opt/website - Our Public Root:
/opt/website/www - A JS Lib We Wrote:
/opt/website/www/share/mylib - So our shell sits in
/opt/websitemost of the time.
And our JS Lib mylib is structured like this.
src/mylib-main.jssrc/mylib-whatever.jssrc/libs/extension1.jssrc/libs/extension2.js
Quick Start
This library provides a vendor bin file. On Windows you will need to run it
as vendor\bin\nether-onescript while upon anything else you will need to
call it as php vendor/bin/nether-onescript - I will use the NotWindows
notation since thats what any sane server is.
php vendor/bin/nether-onescript help
Creating a new OneScript project.
OneScript expects the project source files to be within the src directory.
By default it wil use libs as the module directory looking for the js
extension. So the command required for our example project above:
php vendor/bin/nether-onescript create www/share/mylib \
--files=mylib-main.js,mylib-whatever.js
This will create onescript.json (which can be changed by --filename) in
www/share/jslib/ - in this JSON file you can see all the options
available to change. You will notice that it will have added the main files
you listed on the command line in the Files option, and automatically listed
libs in the Directories option with js in the Extenions option. It also
will have set the OutputFile to onescript.js as well.
Building the OneScript project via CLI.
php vendor/bin/nether-onescript build www/share/mylib/onescript.json
Assuming there are no errors like file permissions or missing files, this
will compile your OneScript project down into onescript.js - your
potentially final file for distribution.
The build system works like so:
- Load the
Filesand bake them into a single file, in the order you specified. - Next it will go through each of the
Directorieslooking for files with the extensions listed inExtensionsand bake them to the end of the file. It will save that as yourOutputFileas the final product. - Once Minify support is done, it will then pass that through the minification
process to create the
OutputMinFile- the minification feature is not yet impelemented.
Building the OneScript project via a live compiler.
Sometimes it is handy, like on your dev server, to have the projects built
automaticaly every time you change them. For my example here I would probably
create a new file called onescript.js.php in my JS project folder.
$project = Nether\OneScript\Project::FromFile(sprintf(
'%s/onescript.json',
dirname(__FILE__)
));
$project->Print = true;
$project->Build();
If you reference this onescript.js.php in your script tag it will be built
every time the page is loaded and the files have changed. You won't realy want
to commit this to your prodution space.
netherphp/onescript 适用场景与选型建议
netherphp/onescript 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 361 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 07 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「javascript」 「compiler」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 netherphp/onescript 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 netherphp/onescript 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 netherphp/onescript 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Generates a Blade directive exporting all of your named Laravel routes. Also provides a nice route() helper function in JavaScript.
Caching and compression for Twig assets (JavaScript and CSS).
A pretty nice way to expose your translation messages to your JavaScript.
A token based Javascript parser/minifier designed for compressing inline scripts on the fly, written in PHP
A token based CSS Document parser and minifier written in PHP
A token based HTML document parser and minifier. Minify HTML documents including inline CSS, Javascript, and SVG's on the fly. Extract document text, attributes, and fragments. Full test suite.
统计信息
- 总下载量: 361
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 12
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2015-07-08