承接 bissolli/php-css-js-minifier 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bissolli/php-css-js-minifier

最新稳定版本:v1.1

Composer 安装命令:

composer require bissolli/php-css-js-minifier

包简介

A PHP Class to merge and minify CSS and JavaScript files.

README 文档

README

Build Status Latest Stable Version Total Downloads License

Composer package to merge and minify a list of Js and Css files.

Installation

Using composer

composer require bissolli/php-css-js-minifier

If you don't have composer

You can download it here.

Code Example

Instantiate the class:

$minifier = new \Bissolli\PhpMinifier\Minifier();

Add all the paths of css files that you wish to merge and minify:

// You can load external assets
$minifier->addCssFile('https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap-reboot.css');

// Use relative path to add the file
$minifier->addCssFile('./data/style1.css');

// Full path is also accepted
$minifier->addCssFile('/{FULL_PATH}/php-css-js-minifier/examples/data/style2.css');

// Array is also allowed
$minifier->addCssFile([
    'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap-reboot.css',
    './data/style1.css',
    '/{FULL_PATH}/php-css-js-minifier/examples/data/style2.css'
]);

Add all the paths of js files that you wish to merge and minify:

// As CSS files, you can load full path, relative and external links.
// Array is also allowed
$minifier->addJsFile('./data/script1.js');
$minifier->addJsFile('/{FULL_PATH}/php-css-js-minifier/examples/data/script2.js');

NOTE: You don't need to add Css AND Js files at the same time, it's possible to add only Css or Js files if needed.

Once all the files are added, let's merge and minify all of them:

// Minify and save css and js files
// Output: ./app.min.css & ./app.min.js
$output = $minifier->minify()->output('./', 'app.min');

// Working with Css only
$output = $minifier->minifyCss()->outputCss('./app.min.css');

// Working with Js only
$output = $minifier->minifyJs()->outputJs('./app.min.js');

License

Released under the MIT license

Thanks

统计信息

  • 总下载量: 2.86k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 0
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-09-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固