Giter Site home page Giter Site logo

php-yui-compressor's Introduction

/*
 * PHP YUICompressor Class (Dual licensed under the MIT)
 * 风吟 (http://fengyin.name/guestbook.php)
 * DEMO http://sweet.fengyin.name/ (yui online compressor)
 ----------------------------------------------------------
 要求: dk 1.4+  php exec() 
 作用: 使用 yuicompressor 批量压缩一个目录的 js 或者 css 文件.也可以对单个文件进行压缩
 ----------------------------------------------------------
 
 //Windows 调用方式:
 

  $yui = new yuicompressor(array(
 'java_home'=>'java', //或自己指定 jdk 安装的 bin 目录 (绝对路径)
 'jar_file'=>'D:\www\htdocs\yuicompressor.jar', 
 'save_path'=>'D:\www\htdocs\results\\', //必须有可写权限
 // -------- 全局设置 --------- //
 'charset'=>'utf-8', //文件的编码
 'line-break'=>false, //在指定的列后插入一个 line-bread 符号
 // -------- javascript 代码的配置选项 --------- //
 'nomunge'=>false,  //只是简单压缩,清除空行空格注释等。
 'semi'=>false, //保留所有的分号
 'optimizations'=>false, //禁止优化代码.
 ));
 
 //对单个文件压缩
 $resutlt = $yui->compress('D:\www\htdocs\swfobject_src.js');
 print_r ($resutlt);
 
 //对目录文件压缩
 $resutlt = $yui->directory('D:\www\htdocs\\');
 print_r($resutlt);
 
 ----------------------------------------------------------
 
 //Linux  调用方式:
 
 $yui = new yuicompressor(array(
 'java_home'=>'java', //或自己指定 jdk 安装的 bin 目录 (绝对路径)
 'jar_file'=>'/home/admin/yuicompressor-2.4.2.jar', 
 'save_path'=>'/home/admin/results/', //必须有可写权限
 // -------- 全局设置 --------- //
 'charset'=>'utf-8', //文件的编码
 'line-break'=>false, //在指定的列后插入一个 line-bread 符号
 // -------- javascript 代码的配置选项 --------- //
 'nomunge'=>false,  //只是简单压缩,清除空行空格注释等。
 'semi'=>false, //保留所有的分号
 'optimizations'=>false, //禁止优化代码.
 ));
 
 //对单个文件压缩
 $resutlt = $yui->compress('/home/admin/style.css');
 print_r ($resutlt);
 
 //对目录文件压缩
 $resutlt = $yui->directory('/home/admin/');
 print_r($resutlt);

php-yui-compressor's People

Stargazers

Quan gan avatar

Watchers

Quan gan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.