Home php教程 PHP源码 php合并压缩js,css实例 (minify实现)

php合并压缩js,css实例 (minify实现)

May 26, 2016 am 08:20 AM

php代码

<?php
namespace Www\Controller;

class MinController extends AdminController {

    /**
     * 资源文件压缩控制器
     */
    public function index(){
        //(1) 设置/min/config.php文件  ,$min_cachePath 有3个设置方式。
                //$min_cachePath = ‘c://WINDOWS//Temp’;
                //$min_cachePath = ‘/tmp’;
                //$min_cachePath = preg_replace(‘/^//d+;/’, ”, session_save_path());
                // 选择第2个,去除//  .设置tmp属性777
        
        //(2) 要压缩的条件请在/ThinkPHP/Library/Vendor/Minify/groupsConfig.php配置
        
        //(3) 调试模式 
                // 在调试模式下,Minify不压缩文件,而是发送合并后的带有行号的文件。要启用该模式,
                // 在config.php中设置为$min_allowDebugFlag为true,并增加"&debug=1" 到你的URIs. 
                // 例如:/min/?f=script1.js,script2.js&debug=1 
                // 注:对于该模式,注释风格的字符串正则表达式可能会导致问题。

        //(4) 页面中使用 不是本地环境时候加载压缩合并的资源文件
                // <if condition="!$Think.const.IS_WIN">
                // <script src="{:U(&#39;/Min/index?g=js&#39;)}"></script>
                // <link rel="stylesheet" href="{:U(&#39;/Min/index?g=css&#39;)}">
                // </if>

        //(5) 安装完毕后删除min/builder/index.php  文件。防止其他人登陆!后期如需编辑再次上传!

        //引入压缩类库
        Vendor(&#39;Minify.index&#39;);
    }    
}
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)