前置工具:
要獲得這個工具,請安裝composer,方便又快速
1.在你的專案下面建立一個composer.json
{
"require":{
"kriswallsmith/assetic": "1.1.*"
}
}
2.安裝套件
$>composer install
裝完會在目錄下看到一個vendor的資料夾:
vendor下面放的東西
3.建立一個測試頁面
include_once 'vendor/autoload.php'; //記得要呼叫autoload.php
use Assetic\Asset\AssetCollection;
use Assetic\Asset\FileAsset;
use Assetic\Asset\GlobAsset;
use Assetic\Filter\GoogleClosure\CompilerApiFilter;
$APP_FOLDER = dirname(dirname(__FILE__)) . "/flicklinkr";
$js = new AssetCollection(array(
// new GlobAsset($APP_FOLDER '/js/*'),
new FileAsset($APP_FOLDER . '/js/plugins/jquery.logger.js'),
), array(
new CompilerApiFilter()
));
//the code is merged when the asset is dumped
header("Content-Type: text/javascript");
echo $js->dump();
?>
4.輸出結果
(function(a){a.console=function(a){"undefined"!=typeof window.console&&console.log(a)}})(jQuery);