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

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;);
    }    
}
Statement
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 Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment