ideatic/tinyfier
Composer 安装命令:
composer require ideatic/tinyfier
包简介
Complete suite for compressing, preprocessing, and optimizing HTML/Javascript/CSS and Images.
README 文档
README
http://www.tinyfier.com
Tinyfier is a complete suite for compressing, preprocessing, and optimizing HTML/Javascript/CSS and Images.
Usage
Optimization on-the-fly (assets_loader)
With Tinyfier you can combine multiple CSS or Javascript files, add extra functionality to CSS (using LESS), remove unnecessary whitespace and comments, and serve them with gzip encoding and optimal client-side cache headers.
For compress and combine your javascript and stylesheets files, all that you need to do is replace the original URL:
By this:
http://example.com/static/tinyfier/tinyfier.php/stylesheet.css
You can also join multiple files into a larger one, reducing the number of HTTP request and making your application fly!
http://example.com/static/tinyfier/tinyfier.php/main.css,user.css,print.css
Also, if you want to pass extra variables to CSS parser, you can do it by adding it into the URL, for example:
http://example.com/static/tinyfier/tinyfier.php/stylesheet.css,base_color=%23ff0000 http://example.com/static/tinyfier/tinyfier.php/stylesheet.css,height=450
Javascript
Tinyfier uses the Google Closure service to compile and minimize Javascript, and, if not available,
rely on JSMinPlus for that operation.
CSS
For CSS files, Tinyfier uses the lessphp parser by leafo for add extra functionality to css files. This include
variables, mixins, expressions, nested blocks, etc. You can see all the available
commands in lessphp documentation. Also, the generated css code is optimized, compressed and the CSS3 vendor prefix (like -webkit or -moz) are added, using css_optimizer.
Also, Tinyfier adds even more functionality:
Sprites
With Tinyfier, create a css sprite it's easy and intuitive. All that you need to
do use the function sprite where the first argument is the image path (relative
to the document) and the second the name of the sprite. E.g.:
.login { background: sprite('images/user_go.png', 'user') no-repeat; } .logout { background: sprite('images/user_delete.png', 'user') no-repeat; }
Gradient generator
Tinyfier include tools to generate CSS3-compatible gradients with backward compatibility with old browsers (through the generation of the equivalent images).
header { background: gradient('vertical', @header_start_color, @header_middle_color 50%, @header_end_color, 1px, 200px); }
(Remember that with lessphp you can use variables everywhere in your code!)
Image embedding
You can also embed images in the document (using the Data URI scheme) with the command inline.
#gplus { background: inline('images/social/gplus.png'); }
Image filters
Another cool function of Tinyfier is the ability for work with image filters.
#lion:hover { background: filter('images/lion.jpg', 'brightness', 50%); }
Internally, Tinyfier uses the php function imagefilter, so you can use all the filters available for it (negate, grayscale, brightness, blur, pixelate and more).
Resize images
If you have to show your image or sprite in differents size, it's as easy as use:
#lion:hover { background: resize('images/lion.jpg', 50%); }
The filter resize can take up to 4 arguments: image url, width (in either px or %), height, and a boolean value than enables or disables aspect ratio (true / false)
More
Please, look in the test file for more examples for using Tinyfier in your project. It's really easy!
ideatic/tinyfier 适用场景与选型建议
ideatic/tinyfier 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.45k 次下载、GitHub Stars 达 11, 最近一次更新时间为 2014 年 04 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「image」 「minification」 「css」 「JS」 「html」 「minify」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ideatic/tinyfier 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ideatic/tinyfier 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ideatic/tinyfier 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Asset Management for PHP
A Twig extension to insert css as inline styles with a tag
Caching and compression for Twig assets (JavaScript and CSS).
Yii2 LightBox image galary widget uses Lightbox v2.10.0 by Lokesh Dhakar
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
PHP client for the Google Closure Compiler API in one file.
统计信息
- 总下载量: 3.45k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-04-24