bradstinson/assets 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

bradstinson/assets

Composer 安装命令:

composer require bradstinson/assets

包简介

A simple assets library. Combine and minify your JS and CSS assets

README 文档

README

Build Status

Assets is yet another CSS/JavaScript minificaton and combination library. However, unlike most other libraries (which rely on Assetic), this ones takes a more simplistic approach.

Assets supports minifying and combining stylesheets and scripts, in an effort to reduce the number and size of http requests needed to load a given page. The generated file is also cached, which prevents an application from having to generate the same file for every new request.

Basic usage

CSS

CSS files can be added using the following command, where "file1.css" and "file2.css" are the CSS files you want to include, and are located at assets/css/file1.css and assets/css/file2.css.

Assets::css('file1.css');
Assets::css('file2.css');

You may also submit files as an array.

Assets::css(array('file1.css', 'file2.css'));

Assets will minify both CSS files and combine them into a single file (which is written to 'assets/cache' directory). The proper tags will then be returned. To include this file in your page, use the following:

echo Assets::renderCss();
/*
Returns something like:
<link rel="stylesheet" href="/assets/cache/3cf89b9f723e22c1caf26f8d4d1fdc31.css">
*/

LESS

Less files can be added using the following command, where "file1.less" is the Less file you want to compile, and is located at assets/css/file1.less.

Assets::less('file1.less');

You may also submit multiple files as an array.

Assets::css(array('file1.less', 'file2.less'));

Your Less files will be automatically compiled and combined with your CSS files into a single file (which is written to 'assets/cache' directory). The proper tags will then be returned.

JS

Javascript files can be added using the following command, where "file1.js" and "file2.js" are the javascript files you want to include, and are located at assets/js/file1.js and assets/js/file2.js.

Assets::js('file1.js');
Assets::js('file2.js');

You may also submit files as an array.

Assets::js(array('file1.js', 'file2.js'));

Assets will minify both JS files and combine them into a single file (which is written to 'assets/cache' directory). The proper tags will then be returned. To include this file in your page, use the following:

echo Assets::renderJs();
/*
Returns something like:
<script src="/assets/cache/9cf2803d8f075cb7d1ad31940738f35e.js"></script>
*/

CoffeeScript

CoffeeScript files can be added using the following command, where "file1.coffee" is the CoffeeScript file you want to compile, and is located at assets/js/file1.coffee.

Assets::coffee('file1.coffee');

You may also submit multiple files as an array.

Assets::coffee(array('file1.coffee', 'file2.coffee'));

Your CoffeeScript files will be automatically compiled and combined with your JS files into a single file (which is written to 'assets/cache' directory). The proper tags will then be returned.

If you would like to generate the CSS and JS tags together, you can call:

echo Assets::render();
/*
Which will return:
<link rel="stylesheet" href="/assets/cache/3cf89b9f723e22c1caf26f8d4d1fdc31.css">
<script src="/assets/cache/9cf2803d8f075cb7d1ad31940738f35e.js"></script>
*/

Configuration

By default, this library assumes the following directory structure:

assets/
   css/
   js/
   cache/
   

However, you are now able to adjust the path to the assets directory (if needed):

Assets::setPath('public/assets/');

BaseURL

Assets::setBaseurl('/');

Groups

This library currently does not offer support for groups. This is because the project I was working on did not require it. If enough requests are made, this may be added in a future version.

Thanks

This asset library was inspired by and uses components from the following libraries:

Contributing

If you have any issues/complaints/suggestions, let me know and I will see if I can implement them as time permits. Also, pull requests are also welcome.

bradstinson/assets 适用场景与选型建议

bradstinson/assets 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 795 次下载、GitHub Stars 达 18, 最近一次更新时间为 2012 年 12 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「assets」 「css」 「JS」 「minify」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 bradstinson/assets 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 18
  • Watchers: 3
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2012-12-04