log1x/sage-svg
Composer 安装命令:
composer require log1x/sage-svg
包简介
A simple package for using inline SVGs in Sage 10 projects.
关键字:
README 文档
README
Sage SVG is a simple package for using inline SVGs in your Sage 10 projects.
Requirements
Installation
Install via Composer:
$ composer require log1x/sage-svg
Usage
By default, the following paths are checked for your SVG (in order):
- If passed an array containing
id, it is assumed to be a WordPress attachment and is ran throughget_attached_file(). - Your default asset manifest (usually
mix-manifest.json). - Path relative to
config('svg.path')which ispublic_path()by default. - Absolute web root path.
Blade Directive
Unless you require advance functionality from somewhere such as a Controller, the best way to use Sage SVG is with the Blade directive straight in your templates.
# Relative path (with dot notation) – resolves to `app/themes/<your theme>/dist/images/logo.svg` by default @svg('images.logo') # Absolute path from webroot with `w-32 h-auto` CSS classes and an aria-label @svg('app/uploads/2019/07/logo.svg', 'w-32 h-auto', ['aria-label' => 'Logo'])
Helper
The easiest way to use SVG outside of a Blade template is the global get_svg() helper function. get_svg() will return false if no image is found.
# Relative path $image = get_svg('images.logo'); # Absolute path from webroot with `w-32 h-auto` CSS classes $image = get_svg('app/uploads/2019/07/logo.svg', 'w-32 h-auto'); # WordPress attachment (e.g. ACF field) with `my-logo` CSS class $image = get_svg( get_field('logo_svg'), 'my-logo' );
Facade
Another option for rendering an SVG is using the SageSvg Facade:
use Log1x\SageSvg\Facades\SageSvg; $image = SageSvg::render('images.logo');
Configuration
The configuration file, svg.php, can be published using Acorn:
$ wp acorn vendor:publish --provider='Log1x\SageSvg\SageSvgServiceProvider'
You can read the DocBlocks in config/svg.php for more details.
Why another SVG Package?
Didn't you author Blade SVG Sage? Why another SVG package?
While I do have my fork of Blade SVG called Blade SVG Sage, I find it rather underwhelming due to the following reasons:
- Unable to handle WordPress attachments
- Unable to inline SVGs that aren't set in a specific path
- Unable to properly use the asset manifest.
- I know QWp6t
Bug Reports
If you discover a bug in Sage SVG, please open an issue.
Contributing
Contributing whether it be through PRs, reporting an issue, or suggesting an idea is encouraged and appreciated.
License
Sage SVG is provided under the MIT License.
log1x/sage-svg 适用场景与选型建议
log1x/sage-svg 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 588.53k 次下载、GitHub Stars 达 122, 最近一次更新时间为 2019 年 07 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「wordpress」 「svg」 「sage」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 log1x/sage-svg 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 log1x/sage-svg 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 log1x/sage-svg 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Composer package to add support for Blade SVG by Adam Wathan to Roots Sage.
PHP class to add Font Awesome 5+'s SVG icons inline without Javascript.
Utility functions to inline SVGs in PHP Projects
Automatically preload fonts from the Sage mix manifest
Generates QR Codes
A set of Blade directives for use with Roots Sage.
统计信息
- 总下载量: 588.53k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 122
- 点击次数: 17
- 依赖项目数: 3
- 推荐数: 4
其他信息
- 授权协议: MIT
- 更新时间: 2019-07-09