定制 zeeyn/evocms-minifier 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

zeeyn/evocms-minifier

Composer 安装命令:

composer require zeeyn/evocms-minifier

包简介

Minifier for evolution cms

README 文档

README

EvolutionCMS 2.* minifier

Install

php artisan package:installrequire zeeyn/evocms-minifier "^1.2.0" in you /core/ folder

How to use

From version 1.2 Minifier calling from Blade directives. Little about them:

  • @minjs(array $files, int $no_laravel_cache = 0, int $minify = 1, string $output_path = '')

  • @mincss(array $files, int $no_laravel_cache = 0, int $minify = 1, string $output_path = '')

  • @minifier(array $files, int $no_laravel_cache = 0, int $minify = 1, string $output_path = '')

As you can see syntax didn't changed too much, as old commands new directives are calling in same places of blade page. Changes touched optimisation spheres, as example:

In old versions you may use minifier not in all documents, but it will prepares for your document every time. Directives are preparing and working only if you call them.

How to use (old versions v.1.1.2 and older)

In released version you have 3 general functions:

  • {{ $minifier->activate( $files, $no_laravel_cache = 0, $minify = 1, $output_path = '' ) }}

  • {{ $minifier->js( $files, $no_laravel_cache = 0, $minify = 1, $output_path = '' ) }}

  • {{ $minifier->css( $files, $no_laravel_cache = 0, $minify = 1, $output_path = '' ) }}

Distinctions:

  • activate() gets $files parameter and automatically gets their extension;
  • js() accepts only *.js files to use;
  • css() accepts only *.css files;

That means that activate() method you can use for css and js files (just place it in right place basing on files extensions) but js() and css() will work only with *.js and *.css files and you must place them on right place (css() in head, js() in bottom of <body>)

Explanation

  • $minifier -- document variable, generates automatically.

  • activate(), css(), js() -- starting function, all that you will use.

  • $files -- array of file paths example: $file = ['/example/path/file.{css or js}', ...]

  • $no_laravel_cache -- flag that signals to script user or not Laravel cache system, default == 0

  • $minify -- integer variable, activates min file generation, default == 1

  • $output_path -- path where generated min file will saves, default -- root folder

  • @minjs -- Blade directive that do the same as $minifier->js() method.

  • @mincss -- Blade directive that do the same as $minifier->css() method.

  • @minifier -- Blade adaptive directive that do the same as $minifier->activate() method.

Example of use

for css:

    ...
    <title>Title</title>
 
     {!! $minifier->activate(['css/style.css','css/style2.css', 'css/style3.css']) !!}

    ...

or directive

    ...
    <title>Title</title>
 
     @mincss(['css/style.css','css/style2.css', 'css/style3.css'])
     //or
     @minifier(['css/style.css','css/style2.css', 'css/style3.css'])
    ...

for js:

     {!! $minifier->activate(['js/script1.js','js/script2.js', 'js/script3.js']) !!}

or directive

    ...
    <title>Title</title>
 
     @minjs(['css/style.css','css/style2.css', 'css/style3.css'])
     //or
     @minifier(['css/style.css','css/style2.css', 'css/style3.css'])

    ...

That's all, now let's see, what in output:

code:

    {!! $minifier->activate(['css/style.css','css/style2.css', 'css/style3.css']) !!}
    //or
    @minifier(['css/style.css','css/style2.css', 'css/style3.css'])

devTool:

<link rel="stylesheet" href="include.511b12e6f2e99d887bebfc7e392c7b80.min.css">

As you can see, minifier creates new file, that contains info from all files before

For js files will be same, but used with <script> tag

Rules of use

if you want to change generated file you must:

  • change raw files (NOT GENERATED)
  • clear site cache*
  • refresh site (F5 ets.)

*In EvolutionCMS 2.* release you can clear cache from manager panel in versions between RC and release you must do php artisan cache:clear from your /core/ folder

in $files array paths to files must stands on order of including:

good:

$files = ['jquery.min.js', 'script.js'] //or another js lib

bad:

$files = ['script.js', 'jquery.min.js'] //or another js lib

with the *.css files that rule using too

More info

  • if you set $minify variable to 0 script will output ol added files with auto version *.*?v=*
  • if you set $no_laravel_cache variable to 1 script will always generate minified file, not recommended for large .css files

zeeyn/evocms-minifier 适用场景与选型建议

zeeyn/evocms-minifier 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 354 次下载、GitHub Stars 达 5, 最近一次更新时间为 2019 年 11 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 zeeyn/evocms-minifier 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 zeeyn/evocms-minifier 我们能提供哪些服务?
定制开发 / 二次开发

基于 zeeyn/evocms-minifier 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 354
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-05