crobays/asset
最新稳定版本:0.9.9
Composer 安装命令:
composer create-project crobays/asset
包简介
Simple asset helper to get asset (image, picture, stylesheet, script) elements or urls. Images and pictures have an option to resized and/or cropped dynamically.
README 文档
README
Simple asset helper to get asset (image, picture, stylesheet, script) elements or urls. Images and pictures have an option to resized and/or cropped dynamically.
Require
"crobays/asset": "dev-master"
Usage
php artisan config:publish crobays/asset creates a config file in your Lavavel project: app/packages/crobays/asset/config.php
Images
Asset::img('my-image.png', ['w' => 400])
grabs images/my-image.png to fit width 400px, saves it to img/my-image___w400.png (also create a @2x version for hi-dpi displays, you need to include retina.js to use this functionality) and returns
<img width="400" src="//assets.example.com/img/my-image___w400.png"
data-src2x="//assets.example.com/img/my-image___w400-@2x.png">
Resize and crop the image by providing both width and height
Asset::img('my-image.png', ['w' => 250, 'h' => 250])
grabs images/my-image.png to fit width 250px and height 250px, saves it to img/my-image___w250-h250.png and returns
<img width="250" height="250" src="//assets.example.com/img/my-image___w250-h250.png"
data-src2x="//assets.example.com/img/my-image___w250-h250-@2x.png">
Provide a size (sizes defined in app/packages/crobays/asset/config.php)
Asset::img('my-image.png', ['s' => 'xlarge'])
makes image and returns
<img width="960" src="//assets.example.com/img/my-image___w960.png"
data-src2x="//assets.example.com/img/my-image___w960-@2x.png">
Provide a special 100% size (defined in the app/packages/crobays/asset/config.php)
Asset::img('my-image.png', ['s' => '100%'])
makes image and returns
<img width="100%" src="//assets.example.com/img/my-image___w800.png"
data-src2x="//assets.example.com/img/my-image___w800-@2x.png">
It allows you to add custom HTML attributes
Asset::img('my-image.png', ['w' => 300, 'class' => 'image'])
makes image and returns
<img width="250" class="image" src="//assets.example.com/img/my-image___w300.png"
data-src2x="//assets.example.com/img/my-image___w300-@2x.png">
Pictures
Asset::pic('picture.jpg', ['w' => 1440])
grabs pictures/picture.jpg to fit width 1440px, saves it to pictures/picture___w1440.jpg (also create a @2x version for hi-dpi displays, you need to include retina.js to use this functionality) and returns
<img width="1440" src="//assets.example.com/pic/picture___w1440.jpg"
data-src2x="//assets.example.com/pic/picture___w1440-@2x.jpg">
(Inherits also all image functionalty found above)
CSS
(default stylesheet defined in the app/packages/crobays/asset/config.php)
Asset::css()
Asset::css('another-style.css')
returns
<link type="text/css" href="//assets.example.com/style.css" rel="stylesheet">
<link type="text/css" href="//assets.example.com/another-style.css" rel="stylesheet">
Javascript
(default script defined in the app/packages/crobays/asset/config.php)
Asset::js()
Asset::js('another-script.js')
returns
<script type="text/javascript" src="//assets.example.com/script.js"></script>
<script type="text/javascript" src="//assets.example.com/another-script.js"></script>
Todo
- phpspec tests
- codeception tests
- comment block documentation
crobays/asset 适用场景与选型建议
crobays/asset 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 34 次下载、GitHub Stars 达 0, 最近一次更新时间为 2014 年 11 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「web」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 crobays/asset 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 crobays/asset 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 crobays/asset 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Model of a web-based resource
Retrieve a WebResourceInterface instance over HTTP
Selectize Theme for Bootstrap 4
Provides command to manage a web library directory
Alfabank REST API integration
A Flickr wrapper to allow you to call the Flickr api with Guzzle as the backend.Goal is to have 100% Flickr api coverage rather than just upload/display photos (currently at 23%).
统计信息
- 总下载量: 34
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-11-17