English 中文(简体)
如何与YUI压缩机使用PHP?
原标题:How to use Minify PHP with YUI compressor?

我谨使用YUI压缩机minification PHP,而不是默认的Jmin。 是否有人的经验?

Right now I am using the groupsConfig.php to combine the JS.

return array(
     jsAll   => array( //contenido/themes/bam/assets/js/jquery.js ,  //contenido/themes/bam/assets/js/modernizr.js , //contenido/themes/bam/assets/js/imgpreload.js ,  //contenido/themes/bam/assets/js/imgpreload.js ,  //contenido/themes/bam/assets/js/history.js , //contenido/themes/bam/assets/js/ajaxify.js ,  //contenido/themes/bam/assets/js/isotope.js ),
     jsHome  => array( //contenido/themes/bam/assets/js/easing.js , //contenido/themes/bam/assets/js/scrollable.js ,  //contenido/themes/bam/assets/js/home.js ),
     cssAll  => array( //contenido/themes/bam/bam.css ),
);

http://code.google.com/p/minification/“rel=“nofollow”>it在主页上说:

Uses an enhanced port of Douglas Crockford s JSMin library and custom classes to minify CSS and HTML

I have the following code in config.php, but I get a 500 error when trying to view the combined js file:

function yuiJs($js) {
    require_once  /lib/Minify/YUICompressor.php ; 
    Minify_YUICompressor::$jarFile =  /lib/yuicompressor-2.4.2.jar ; 
    Minify_YUICompressor::$tempDir =  /temp ; 
    return Minify_YUICompressor::minifyJs($js); 
}
$min_serveOptions[ minifiers ][ application/x-javascript ] =  yuiJs ;

It also appears that there are several lines in lib/Minify/YUICompressor.php that need to be configured, and I m not sure if I m doing it right:

class Minify_YUICompressor {

    /**
     * Filepath of the YUI Compressor jar file. This must be set before
     * calling minifyJs() or minifyCss().
     *
     * @var string
     */
    public static $jarFile =  ../yuicompressor-2.4.2.jar ;

    /**
     * Writable temp directory. This must be set before calling minifyJs()
     * or minifyCss().
     *
     * @var string
     */
    public static $tempDir =  ../../temp/ ;

    /**
     * Filepath of "java" executable (may be needed if not in shell s PATH)
     *
     * @var string
     */
    public static $javaExecutable =  java ;
问题回答

我在窗口上也存在同样的问题。 看来,为了管理 y压缩机,需要起诉。 因此,必须取消YUICompressor.php的可执行检查。

#132 


private static function _prepare()
    {
        if (! is_file(self::$jarFile)) {
            throw new Exception( Minify_YUICompressor : $jarFile( .self::$jarFile. ) is not a valid file. );
        }
//         if (! is_executable(self::$jarFile)) {
//             throw new Exception( Minify_YUICompressor : $jarFile( .self::$jarFile. ) is not executable. );
//         }
        if (! is_dir(self::$tempDir)) {
            throw new Exception( Minify_YUICompressor : $tempDir( .self::$tempDir. ) is not a valid direcotry. );
        }
        if (! is_writable(self::$tempDir)) {
            throw new Exception( Minify_YUICompressor : $tempDir( .self::$tempDir. ) is not writable. );
        }
    }

and that works fine.





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签