ampedweb/laravel-glide-in-a-box
Composer 安装命令:
composer require ampedweb/laravel-glide-in-a-box
包简介
Out of the box solution for Glide PHP for Laravel
README 文档
README
Out of the box solution for Glide PHP for Laravel providing a fluent interface for the Glide API.
Full Docs & Examples are here: https://ampedweb.github.io/laravel-glide-in-a-box/
If you would like to use JUST the Fluent URL Builder in your project you can find that here: https://github.com/ampedweb/glide-url-helper. Docs are currently a work in progress there...!
Requirements
- PHP >= 7.3 with the following extensions:
- Exif
- GD or ImageMagick
- league/glide-laravel": "^1.6",
Features
- Automatically signed urls when using the
glide_url()helper function. - A fluent interface for all glide image api see here: https://glide.thephpleague.com
Installation
composer require ampedweb/laravel-glide-in-a-box
Publish the config file:
php artisan vendor:publish --tag=glideinabox
Basic Usage
The base url "out of the box" for all glide image url requests is "/img/". You can adjust this in the glideinabox.php config file once you have published it.
Using the glide_url() helper function should make building your image urls simple.
An example using a preset as a base and then making a few alterations using the fluent methods:
glide_url($pathToYourImageFile)->preset('medium')->filter('sepia')->url(); // You can also cast the FluentUrlBuilder to a string: $url = (string)glide_url($pathToYourImageFile)->preset('medium')->filter('sepia'); // Or print it: print glide_url($pathToYourImageFile)->preset('medium')->filter('sepia'); // Or use it directly in your blade templates: {{ glide_url($pathToYourImageFile)->preset('medium')->filter('sepia') }}
There are also predefined constants if you prefer using those rather than strings, e.g:
use AmpedWeb\GlideUrl\Interfaces\Filter; glide_url($pathToYourImageFile)->preset('medium')->filter(Filter::SEPIA)->url();
You can also build a completely custom image with no preset. Below is a 200x100 px cropped webp image at 50% quality:
use AmpedWeb\GlideUrl\Interfaces\Fit; glide_url($pathToYourImageFile)->size(200,100)->fit(Fit::CROP)->webp(50)->url();
Always remember to call the ->url() method when you are done configuring your image.
Extension
If you would like to use your own image controller but still use the base functionality from the package then you will need to extend:
AmpedWeb\GlideInABox\Controller\GlideImageController;
Running Tests:
php vendor/bin/phpunit
ampedweb/laravel-glide-in-a-box 适用场景与选型建议
ampedweb/laravel-glide-in-a-box 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 967 次下载、GitHub Stars 达 3, 最近一次更新时间为 2020 年 10 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 ampedweb/laravel-glide-in-a-box 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ampedweb/laravel-glide-in-a-box 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 967
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-10-25