douxu2467 2015-03-07 20:53
浏览 39

谷歌关闭通过PHP与Externs

I am trying to use Google Closure but called through a php library.

This is the code I'm trying to work with

https://code.google.com/p/php-closure/

So far it seems to be working well. However I now need to use the "Externs" feature of Google Closure.

I have gone through the php library code but I am unsure on how to add this feature. The library appears to call the Google Closure online API code, so I assume to add the externs feature I just need to pass the correct string attached to the correct variable.

I won't post the entire library here as it would be hard to read, but the efforts I've made to incorporate this feature.

To begin I added the variable to the library

var $_srcs = array();
var $_mode = "WHITESPACE_ONLY";
var $_warning_level = "DEFAULT";
var $_use_closure_library = false;
var $_pretty_print = false;
var $_debug = true;
var $_cache_dir = "";
var $_code_url_prefix = "";
var $_extern_file = ""; //my new code

add to the hash function

function _getHash() {
return md5(implode(",", $this->_srcs) . "-" .
    $this->_mode . "-" .
    $this->_warning_level . "-" .
    $this->_use_closure_library . "-" .
    $this->_pretty_print . "-" .
    $this->_extern_file . "-" .     //here again
    $this->_debug);
}

add to get params list

function _getParamList() {
$params = array();
...
$params["warning_level"] = $this->_warning_level;
$params["extern_file"] = $this->_extern_file;      //again here
if ($this->_pretty_print) $params["formatting"] = "pretty_print";
if ($this->_use_closure_library) $params["use_closure_library"] = "true";
$params["output_info_1"] = "compiled_code";
$params["output_info_2"] = "statistics";
$params["output_info_3"] = "warnings";
$params["output_info_4"] = "errors";
return $params;
}

my add externs file function

function externs($file) {
  $this->_extern_file = $file;
  return $this;
}

then my user call

$c->add("js/my-app.js")
->add("js/popup.js")
->externs("js/externs.js")    //new code
->cacheDir("/tmp/js-cache/")
->write();

When trying to execute the code I get the same result as the original code. It appears the externs file that I'm trying to pass isn't being processed.

If anyone else is interested in this feature / library please feel free to post any ideas.

Thanks.

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 用visual studi code完成html页面
    • ¥15 聚类分析或者python进行数据分析
    • ¥15 逻辑谓词和消解原理的运用
    • ¥15 三菱伺服电机按启动按钮有使能但不动作
    • ¥15 js,页面2返回页面1时定位进入的设备
    • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
    • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
    • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
    • ¥20 腾讯企业邮箱邮件可以恢复么
    • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?